mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Features;
|
|
|
|
namespace Volo.Abp.FeatureManagement;
|
|
|
|
public abstract class FeatureManagementProvider : IFeatureManagementProvider
|
|
{
|
|
public abstract string Name { get; }
|
|
|
|
protected IFeatureManagementStore Store { get; }
|
|
|
|
protected FeatureManagementProvider(IFeatureManagementStore store)
|
|
{
|
|
Store = store;
|
|
}
|
|
|
|
public virtual bool Compatible(string providerName)
|
|
{
|
|
return providerName == Name;
|
|
}
|
|
|
|
public virtual Task<IAsyncDisposable> HandleContextAsync(string providerName, string providerKey)
|
|
{
|
|
return Task.FromResult<IAsyncDisposable>(NullAsyncDisposable.Instance);
|
|
}
|
|
|
|
public virtual async Task<string> GetOrNullAsync(FeatureDefinition feature, string providerKey)
|
|
{
|
|
return await Store.GetOrNullAsync(feature.Name, Name, await NormalizeProviderKeyAsync(providerKey));
|
|
}
|
|
|
|
public virtual async Task SetAsync(FeatureDefinition feature, string value, string providerKey)
|
|
{
|
|
await Store.SetAsync(feature.Name, value, Name, await NormalizeProviderKeyAsync(providerKey));
|
|
}
|
|
|
|
public virtual async Task ClearAsync(FeatureDefinition feature, string providerKey)
|
|
{
|
|
await Store.DeleteAsync(feature.Name, Name, await NormalizeProviderKeyAsync(providerKey));
|
|
}
|
|
|
|
protected virtual Task<string> NormalizeProviderKeyAsync(string providerKey)
|
|
{
|
|
return Task.FromResult(providerKey);
|
|
}
|
|
}
|
|
|