From 52583571cc79baf4fad72180d1f5b21fcd210db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Wed, 18 Mar 2020 13:16:16 +0300 Subject: [PATCH] virtualized --- .../ConfigurationSettingManagementProvider.cs | 6 +++--- .../DefaultValueSettingManagementProvider.cs | 6 +++--- .../SettingManagementProvider.cs | 2 +- .../SettingManagementStore.cs | 8 +++---- .../Abp/SettingManagement/SettingStore.cs | 2 +- .../EfCoreSettingRepository.cs | 4 ++-- .../MongoDB/MongoSettingRepository.cs | 4 ++-- .../SettingManagementMainMenuContributor.cs | 4 ++-- .../Pages/SettingManagement/Index.cshtml.cs | 21 ++++++++++--------- 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs index c2f7654fd8..d742aab4a4 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/ConfigurationSettingManagementProvider.cs @@ -16,17 +16,17 @@ namespace Volo.Abp.SettingManagement Configuration = configuration; } - public Task GetOrNullAsync(SettingDefinition setting, string providerKey) + public virtual Task 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."); } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs index 3bb4ae2655..0be00126d3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/DefaultValueSettingManagementProvider.cs @@ -8,17 +8,17 @@ namespace Volo.Abp.SettingManagement { public string Name => DefaultValueSettingValueProvider.ProviderName; - public Task GetOrNullAsync(SettingDefinition setting, string providerKey) + public virtual Task 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."); } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs index 2859b2e7f4..460a9f02f5 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementProvider.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.SettingManagement SettingManagementStore = settingManagementStore; } - public async Task GetOrNullAsync(SettingDefinition setting, string providerKey) + public virtual async Task GetOrNullAsync(SettingDefinition setting, string providerKey) { return await SettingManagementStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey)); } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs index 8c9cfc8684..d7a8b0ccb1 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManagementStore.cs @@ -24,13 +24,13 @@ namespace Volo.Abp.SettingManagement Cache = cache; } - public async Task GetOrNullAsync(string name, string providerName, string providerKey) + public virtual async Task 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> GetListAsync(string providerName, string providerKey) + public virtual async Task> 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) diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs index 91b389c354..c38f915bf5 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingStore.cs @@ -13,7 +13,7 @@ namespace Volo.Abp.SettingManagement ManagementStore = managementStore; } - public Task GetOrNullAsync(string name, string providerName, string providerKey) + public virtual Task GetOrNullAsync(string name, string providerName, string providerKey) { return ManagementStore.GetOrNullAsync(name, providerName, providerKey); } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs index 86b31036d1..66fe5e2eff 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore { } - public async Task FindAsync(string name, string providerName, string providerKey) + public virtual async Task FindAsync(string name, string providerName, string providerKey) { return await DbSet .FirstOrDefaultAsync( @@ -23,7 +23,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore ); } - public async Task> GetListAsync(string providerName, string providerKey) + public virtual async Task> GetListAsync(string providerName, string providerKey) { return await DbSet .Where( diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs index 56516dcbd0..8ad74b914a 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs @@ -16,12 +16,12 @@ namespace Volo.Abp.SettingManagement.MongoDB } - public async Task FindAsync(string name, string providerName, string providerKey) + public virtual async Task FindAsync(string name, string providerName, string providerKey) { return await GetMongoQueryable().FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey); } - public async Task> GetListAsync(string providerName, string providerKey) + public virtual async Task> GetListAsync(string providerName, string providerKey) { return await GetMongoQueryable().Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync(); } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs index 8aee74c56c..59c0518d3c 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs @@ -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 CheckAnyOfPagePermissionsGranted( + protected virtual async Task CheckAnyOfPagePermissionsGranted( SettingManagementPageOptions settingManagementPageOptions, SettingPageCreationContext settingPageCreationContext) { diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs index 1fdba05707..31602957cf 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs @@ -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 options, - IServiceProvider serviceProvider) + public IndexModel(IOptions 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; + } } } \ No newline at end of file