|
|
@ -34,7 +34,7 @@ public class SettingManager : ISettingManager, ISingletonDependency
|
|
|
|
protected virtual List<ISettingManagementProvider> CreateSettingManagementProviders()
|
|
|
|
protected virtual List<ISettingManagementProvider> CreateSettingManagementProviders()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using var scope = ServiceProvider.CreateScope();
|
|
|
|
using var scope = ServiceProvider.CreateScope();
|
|
|
|
|
|
|
|
|
|
|
|
return Options.Providers
|
|
|
|
return Options.Providers
|
|
|
|
.Select(p => (scope.ServiceProvider.GetRequiredService(p) as ISettingManagementProvider)!)
|
|
|
|
.Select(p => (scope.ServiceProvider.GetRequiredService(p) as ISettingManagementProvider)!)
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
@ -112,6 +112,50 @@ public class SettingManager : ISettingManager, ISingletonDependency
|
|
|
|
return settingValues.Values.ToList();
|
|
|
|
return settingValues.Values.ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<Dictionary<string, SettingValue>> GetAllByPrefixAsync(string namePrefix, string providerName,
|
|
|
|
|
|
|
|
string? providerKey, bool fallback = false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Check.NotNull(providerName, nameof(providerName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var setting = await SettingDefinitionManager.GetAsync(namePrefix);
|
|
|
|
|
|
|
|
var providers = Enumerable.Reverse(Providers)
|
|
|
|
|
|
|
|
.SkipWhile(c => c.Name != providerName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fallback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
providers = providers.TakeWhile(c => c.Name == providerName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var providerList = providers.Reverse().ToList();
|
|
|
|
|
|
|
|
if (!providerList.Any())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new Dictionary<string, SettingValue>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var settingValues = new Dictionary<string, SettingValue>();
|
|
|
|
|
|
|
|
foreach (var provider in providerList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var list = await provider.GetByPrefixAsync(
|
|
|
|
|
|
|
|
setting.Name,
|
|
|
|
|
|
|
|
provider.Name == providerName ? providerKey : null
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach (var sv in list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (setting.IsEncrypted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sv.Value = SettingEncryptionService.Decrypt(setting, sv.Value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sv.Value != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
settingValues[sv.Name] = sv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return settingValues;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task SetAsync(string name, string? value, string providerName, string? providerKey,
|
|
|
|
public virtual async Task SetAsync(string name, string? value, string providerName, string? providerKey,
|
|
|
|
bool forceToSet = false)
|
|
|
|
bool forceToSet = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|