Merge pull request #3183 from abpframework/Cotur-Virtualization-SettingManagement

Make Setting Management module services easily overridable by inheritance
pull/3205/head
Halil İbrahim Kalkan 5 years ago committed by GitHub
commit df80a63bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,17 +16,17 @@ namespace Volo.Abp.SettingManagement
Configuration = configuration;
}
public Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
return Task.FromResult(Configuration[ConfigurationSettingValueProvider.ConfigurationNamePrefix + setting.Name]);
}
public Task SetAsync(SettingDefinition setting, string value, string providerKey)
public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
throw new AbpException($"Can not set a setting value to the application configuration.");
}
public Task ClearAsync(SettingDefinition setting, string providerKey)
public virtual Task ClearAsync(SettingDefinition setting, string providerKey)
{
throw new AbpException($"Can not set a setting value to the application configuration.");
}

@ -8,17 +8,17 @@ namespace Volo.Abp.SettingManagement
{
public string Name => DefaultValueSettingValueProvider.ProviderName;
public Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
public virtual Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
return Task.FromResult(setting.DefaultValue);
}
public Task SetAsync(SettingDefinition setting, string value, string providerKey)
public virtual Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
throw new AbpException($"Can not set default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation.");
}
public Task ClearAsync(SettingDefinition setting, string providerKey)
public virtual Task ClearAsync(SettingDefinition setting, string providerKey)
{
throw new AbpException($"Can not clear default value of a setting. It is only possible while defining the setting in a {typeof(ISettingDefinitionProvider)} implementation.");
}

@ -15,7 +15,7 @@ namespace Volo.Abp.SettingManagement
SettingManagementStore = settingManagementStore;
}
public async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
public virtual async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
return await SettingManagementStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}

@ -24,13 +24,13 @@ namespace Volo.Abp.SettingManagement
Cache = cache;
}
public async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
public virtual async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
{
var cacheItem = await GetCacheItemAsync(name, providerName, providerKey);
return cacheItem.Value;
}
public async Task SetAsync(string name, string value, string providerName, string providerKey)
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey)
{
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
if (setting == null)
@ -45,13 +45,13 @@ namespace Volo.Abp.SettingManagement
}
}
public async Task<List<SettingValue>> GetListAsync(string providerName, string providerKey)
public virtual async Task<List<SettingValue>> GetListAsync(string providerName, string providerKey)
{
var settings = await SettingRepository.GetListAsync(providerName, providerKey);
return settings.Select(s => new SettingValue(s.Name, s.Value)).ToList();
}
public async Task DeleteAsync(string name, string providerName, string providerKey)
public virtual async Task DeleteAsync(string name, string providerName, string providerKey)
{
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
if (setting != null)

@ -13,7 +13,7 @@ namespace Volo.Abp.SettingManagement
ManagementStore = managementStore;
}
public Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
public virtual Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
{
return ManagementStore.GetOrNullAsync(name, providerName, providerKey);
}

@ -15,7 +15,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
{
}
public async Task<Setting> FindAsync(string name, string providerName, string providerKey)
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{
return await DbSet
.FirstOrDefaultAsync(
@ -23,7 +23,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
);
}
public async Task<List<Setting>> GetListAsync(string providerName, string providerKey)
public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey)
{
return await DbSet
.Where(

@ -16,12 +16,12 @@ namespace Volo.Abp.SettingManagement.MongoDB
}
public async Task<Setting> FindAsync(string name, string providerName, string providerKey)
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable().FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
}
public async Task<List<Setting>> GetListAsync(string providerName, string providerKey)
public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey)
{
return await GetMongoQueryable().Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
}

@ -12,7 +12,7 @@ namespace Volo.Abp.SettingManagement.Web.Navigation
{
public class SettingManagementMainMenuContributor : IMenuContributor
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
public virtual async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name != StandardMenus.Main)
{
@ -43,7 +43,7 @@ namespace Volo.Abp.SettingManagement.Web.Navigation
);
}
private async Task<bool> CheckAnyOfPagePermissionsGranted(
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted(
SettingManagementPageOptions settingManagementPageOptions,
SettingPageCreationContext settingPageCreationContext)
{

@ -9,25 +9,26 @@ namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement
{
public SettingPageCreationContext SettingPageCreationContext { get; private set; }
private readonly SettingManagementPageOptions _options;
private readonly IServiceProvider _serviceProvider;
protected SettingManagementPageOptions Options { get; }
public IndexModel(
IOptions<SettingManagementPageOptions> options,
IServiceProvider serviceProvider)
public IndexModel(IOptions<SettingManagementPageOptions> options)
{
_serviceProvider = serviceProvider;
_options = options.Value;
Options = options.Value;
}
public async Task OnGetAsync()
public virtual async Task OnGetAsync()
{
SettingPageCreationContext = new SettingPageCreationContext(_serviceProvider);
SettingPageCreationContext = new SettingPageCreationContext(ServiceProvider);
foreach (var contributor in _options.Contributors)
foreach (var contributor in Options.Contributors)
{
await contributor.ConfigureAsync(SettingPageCreationContext);
}
}
public virtual Task OnPostAsync()
{
return Task.CompletedTask;
}
}
}
Loading…
Cancel
Save