You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Volo.Abp.Settings;
|
|
|
|
namespace NPin.Framework.SettingManagement.Domain;
|
|
|
|
/// <summary>
|
|
/// 设置管理器提供者
|
|
/// </summary>
|
|
public abstract class SettingManagementProvider : ISettingManagementProvider
|
|
{
|
|
public abstract string Name { get; }
|
|
|
|
protected ISettingManagementStore SettingManagementStore { get; }
|
|
|
|
public SettingManagementProvider(ISettingManagementStore settingManagementStore)
|
|
{
|
|
SettingManagementStore = settingManagementStore;
|
|
}
|
|
|
|
public virtual async Task<string?> 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;
|
|
}
|
|
} |