Created EditionFeatureValueProvider

pull/877/head
Halil ibrahim Kalkan 6 years ago
parent 34f2e9eeda
commit c5c12209b5

@ -26,6 +26,7 @@ namespace Volo.Abp.Features
context.Services.Configure<FeatureOptions>(options =>
{
options.ValueProviders.Add<DefaultValueFeatureValueProvider>();
options.ValueProviders.Add<EditionFeatureValueProvider>();
options.ValueProviders.Add<TenantFeatureValueProvider>();
});
}

@ -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<string> GetOrNullAsync(FeatureDefinition feature)
{
var editionId = PrincipalAccessor.Principal.FindEditionId();
if (editionId == null)
{
return null;
}
return await FeatureStore.GetOrNullAsync(feature.Name, Name, editionId);
}
}
}
Loading…
Cancel
Save