using NPin.Framework.SettingManagement.Domain.Provider; using NPin.Framework.SettingManagement.Domain.Store; using Volo.Abp.Settings; namespace NPin.Framework.SettingManagement.Domain; /// /// 设置管理器提供者 /// public abstract class SettingManagementProvider : ISettingManagementProvider { public abstract string Name { get; } protected ISettingManagementStore SettingManagementStore { get; } public SettingManagementProvider(ISettingManagementStore settingManagementStore) { SettingManagementStore = settingManagementStore; } public virtual async Task GetOrNullAsync(SettingDefinition setting, string providerKey) { return await SettingManagementStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey)); } public virtual async Task SetAsync(SettingDefinition setting, string value, string providerKey) { await SettingManagementStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey)); } public virtual async Task ClearAsync(SettingDefinition setting, string providerKey) { await SettingManagementStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey)); } protected virtual string? NormalizeProviderKey(string? providerKey) { return providerKey; } }