From c5c12209b5749115828d0f0efa01592c3442270e Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 14 Mar 2019 13:39:14 +0300 Subject: [PATCH] Created EditionFeatureValueProvider --- .../Volo/Abp/Features/AbpFeaturesModule.cs | 1 + .../Features/EditionFeatureValueProvider.cs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/AbpFeaturesModule.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/AbpFeaturesModule.cs index 8730c04591..fed872890c 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/AbpFeaturesModule.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/AbpFeaturesModule.cs @@ -26,6 +26,7 @@ namespace Volo.Abp.Features context.Services.Configure(options => { options.ValueProviders.Add(); + options.ValueProviders.Add(); options.ValueProviders.Add(); }); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs new file mode 100644 index 0000000000..c84f2d52c6 --- /dev/null +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs @@ -0,0 +1,32 @@ +using System.Security.Principal; +using System.Threading.Tasks; +using Volo.Abp.Security.Claims; + +namespace Volo.Abp.Features +{ + public class EditionFeatureValueProvider : FeatureValueProvider + { + public const string ProviderName = "Edition"; + + public override string Name => ProviderName; + + protected ICurrentPrincipalAccessor PrincipalAccessor; + + public EditionFeatureValueProvider(IFeatureStore featureStore, ICurrentPrincipalAccessor principalAccessor) + : base(featureStore) + { + PrincipalAccessor = principalAccessor; + } + + public override async Task GetOrNullAsync(FeatureDefinition feature) + { + var editionId = PrincipalAccessor.Principal.FindEditionId(); + if (editionId == null) + { + return null; + } + + return await FeatureStore.GetOrNullAsync(feature.Name, Name, editionId); + } + } +} \ No newline at end of file