From b87a09271b369d1372e9eef452512ac3a765caf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Wed, 18 Mar 2020 11:43:27 +0300 Subject: [PATCH] virtualized --- .../FeatureManagement/FeatureAppService.cs | 23 ++++++++----------- .../DefaultValueFeatureManagementProvider.cs | 6 ++--- .../FeatureManagementProvider.cs | 2 +- .../FeatureManagementStore.cs | 6 ++--- .../Abp/FeatureManagement/FeatureStore.cs | 2 +- .../EfCoreFeatureValueRepository.cs | 4 ++-- .../FeatureManagement/FeaturesController.cs | 12 +++++----- .../MongoDB/MongoFeatureValueRepository.cs | 4 ++-- .../FeatureManagementModal.cshtml.cs | 12 +++++----- 9 files changed, 34 insertions(+), 37 deletions(-) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs index 097ea7ffa0..24b04b7013 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs @@ -17,18 +17,15 @@ namespace Volo.Abp.FeatureManagement { protected FeatureManagementOptions Options { get; } - private readonly IFeatureManager _featureManager; - private readonly IFeatureDefinitionManager _featureDefinitionManager; - private readonly IStringLocalizerFactory _stringLocalizerFactory; + protected IFeatureManager FeatureManager { get; } + protected IFeatureDefinitionManager FeatureDefinitionManager { get; } public FeatureAppService(IFeatureManager featureManager, IFeatureDefinitionManager featureDefinitionManager, - IStringLocalizerFactory stringLocalizerFactory, IOptions options) { - _featureManager = featureManager; - _featureDefinitionManager = featureDefinitionManager; - _stringLocalizerFactory = stringLocalizerFactory; + FeatureManager = featureManager; + FeatureDefinitionManager = featureDefinitionManager; Options = options.Value; } @@ -36,7 +33,7 @@ namespace Volo.Abp.FeatureManagement { await CheckProviderPolicy(providerName); - var featureDefinitions = _featureDefinitionManager.GetAll(); + var featureDefinitions = FeatureDefinitionManager.GetAll(); var features = new List(); foreach (var featureDefinition in featureDefinitions) @@ -44,11 +41,11 @@ namespace Volo.Abp.FeatureManagement features.Add(new FeatureDto { Name = featureDefinition.Name, - DisplayName = featureDefinition.DisplayName?.Localize(_stringLocalizerFactory), + DisplayName = featureDefinition.DisplayName?.Localize(StringLocalizerFactory), ValueType = featureDefinition.ValueType, - Description = featureDefinition.Description?.Localize(_stringLocalizerFactory), + Description = featureDefinition.Description?.Localize(StringLocalizerFactory), ParentName = featureDefinition.Parent?.Name, - Value = await _featureManager.GetOrNullAsync(featureDefinition.Name, providerName, providerKey) + Value = await FeatureManager.GetOrNullAsync(featureDefinition.Name, providerName, providerKey) }); } @@ -63,11 +60,11 @@ namespace Volo.Abp.FeatureManagement foreach (var feature in input.Features) { - await _featureManager.SetAsync(feature.Name, feature.Value, providerName, providerKey); + await FeatureManager.SetAsync(feature.Name, feature.Value, providerName, providerKey); } } - private void SetFeatureDepth(List features, string providerName, string providerKey, + protected virtual void SetFeatureDepth(List features, string providerName, string providerKey, FeatureDto parentFeature = null, int depth = 0) { foreach (var feature in features) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/DefaultValueFeatureManagementProvider.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/DefaultValueFeatureManagementProvider.cs index aa20684d3a..6c501166e2 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/DefaultValueFeatureManagementProvider.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/DefaultValueFeatureManagementProvider.cs @@ -8,17 +8,17 @@ namespace Volo.Abp.FeatureManagement { public string Name => DefaultValueFeatureValueProvider.ProviderName; - public Task GetOrNullAsync(FeatureDefinition feature, string providerKey) + public virtual Task GetOrNullAsync(FeatureDefinition feature, string providerKey) { return Task.FromResult(feature.DefaultValue); } - public Task SetAsync(FeatureDefinition feature, string value, string providerKey) + public virtual Task SetAsync(FeatureDefinition feature, string value, string providerKey) { throw new AbpException($"Can not set default value of a feature. It is only possible while defining the feature in a {typeof(IFeatureDefinitionProvider)} implementation."); } - public Task ClearAsync(FeatureDefinition feature, string providerKey) + public virtual Task ClearAsync(FeatureDefinition feature, string providerKey) { throw new AbpException($"Can not clear default value of a feature. It is only possible while defining the feature in a {typeof(IFeatureDefinitionProvider)} implementation."); } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementProvider.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementProvider.cs index 1d0c59773b..499d396e60 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementProvider.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementProvider.cs @@ -14,7 +14,7 @@ namespace Volo.Abp.FeatureManagement Store = store; } - public async Task GetOrNullAsync(FeatureDefinition feature, string providerKey) + public virtual async Task GetOrNullAsync(FeatureDefinition feature, string providerKey) { return await Store.GetOrNullAsync(feature.Name, Name, NormalizeProviderKey(providerKey)); } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementStore.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementStore.cs index 94c4d48067..8f3574d4a2 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementStore.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManagementStore.cs @@ -21,13 +21,13 @@ namespace Volo.Abp.FeatureManagement 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 featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); if (featureValue == null) @@ -42,7 +42,7 @@ namespace Volo.Abp.FeatureManagement } } - public async Task DeleteAsync(string name, string providerName, string providerKey) + public virtual async Task DeleteAsync(string name, string providerName, string providerKey) { var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); if (featureValue != null) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureStore.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureStore.cs index 23d5ea7d50..2f8dfbab34 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureStore.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureStore.cs @@ -13,7 +13,7 @@ namespace Volo.Abp.FeatureManagement FeatureManagementStore = featureManagementStore; } - public Task GetOrNullAsync( + public virtual Task GetOrNullAsync( string name, string providerName, string providerKey) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs index 9545ac36b4..34a6c1bbb3 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.FeatureManagement.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.FeatureManagement.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/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs index ea0bfd16ee..a56ff24275 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs @@ -8,21 +8,21 @@ namespace Volo.Abp.FeatureManagement [Area("abp")] public class FeaturesController : AbpController, IFeatureAppService { - private readonly IFeatureAppService _featureAppService; + protected IFeatureAppService FeatureAppService { get; } public FeaturesController(IFeatureAppService featureAppService) { - _featureAppService = featureAppService; + FeatureAppService = featureAppService; } - public Task GetAsync(string providerName, string providerKey) + public virtual Task GetAsync(string providerName, string providerKey) { - return _featureAppService.GetAsync(providerName, providerKey); + return FeatureAppService.GetAsync(providerName, providerKey); } - public Task UpdateAsync(string providerName, string providerKey, UpdateFeaturesDto input) + public virtual Task UpdateAsync(string providerName, string providerKey, UpdateFeaturesDto input) { - return _featureAppService.UpdateAsync(providerName, providerKey, input); + return FeatureAppService.UpdateAsync(providerName, providerKey, input); } } } \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs index f57d125dce..7db01d5288 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs @@ -16,13 +16,13 @@ namespace Volo.Abp.FeatureManagement.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) diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs index d9e0d7b2c4..fd32f69d63 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/FeatureManagementModal.cshtml.cs @@ -25,21 +25,21 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement public FeatureListDto FeatureListDto { get; set; } - private readonly IFeatureAppService _featureAppService; + protected IFeatureAppService FeatureAppService { get; } public FeatureManagementModal(IFeatureAppService featureAppService) { ObjectMapperContext = typeof(AbpFeatureManagementWebModule); - _featureAppService = featureAppService; + FeatureAppService = featureAppService; } - public async Task OnGetAsync() + public virtual async Task OnGetAsync() { - FeatureListDto = await _featureAppService.GetAsync(ProviderName, ProviderKey); + FeatureListDto = await FeatureAppService.GetAsync(ProviderName, ProviderKey); } - public async Task OnPostAsync() + public virtual async Task OnPostAsync() { var features = new UpdateFeaturesDto { @@ -50,7 +50,7 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement }).ToList() }; - await _featureAppService.UpdateAsync(ProviderName, ProviderKey, features); + await FeatureAppService.UpdateAsync(ProviderName, ProviderKey, features); return NoContent(); }