mirror of https://github.com/abpframework/abp.git
10 changed files with 21 additions and 111 deletions
@ -1,30 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.MultiTenancy; |
|
||||
|
|
||||
namespace Volo.Abp.Features |
|
||||
{ |
|
||||
public class HostFeatureValueProvider : FeatureValueProvider |
|
||||
{ |
|
||||
public const string ProviderName = "H"; |
|
||||
|
|
||||
public override string Name => ProviderName; |
|
||||
|
|
||||
protected ICurrentTenant CurrentTenant { get; } |
|
||||
|
|
||||
public HostFeatureValueProvider(IFeatureStore featureStore, ICurrentTenant currentTenant) |
|
||||
: base(featureStore) |
|
||||
{ |
|
||||
CurrentTenant = currentTenant; |
|
||||
} |
|
||||
|
|
||||
public override async Task<string> GetOrNullAsync(FeatureDefinition feature) |
|
||||
{ |
|
||||
if (CurrentTenant.Id.HasValue || !feature.IsAvailableToHost) |
|
||||
{ |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
return await FeatureStore.GetOrNullAsync(feature.Name, Name, null); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,59 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
using Volo.Abp.Features; |
|
||||
using Volo.Abp.MultiTenancy; |
|
||||
|
|
||||
namespace Volo.Abp.FeatureManagement |
|
||||
{ |
|
||||
public class HostFeatureManagementProvider : FeatureManagementProvider, ITransientDependency |
|
||||
{ |
|
||||
public override string Name => HostFeatureValueProvider.ProviderName; |
|
||||
|
|
||||
protected ICurrentTenant CurrentTenant { get; } |
|
||||
|
|
||||
public HostFeatureManagementProvider( |
|
||||
IFeatureManagementStore store, |
|
||||
ICurrentTenant currentTenant) |
|
||||
: base(store) |
|
||||
{ |
|
||||
CurrentTenant = currentTenant; |
|
||||
} |
|
||||
|
|
||||
public override async Task<string> GetOrNullAsync(FeatureDefinition feature, string providerKey) |
|
||||
{ |
|
||||
if (IsHostSide(feature)) |
|
||||
{ |
|
||||
return await Store.GetOrNullAsync(feature.Name, Name, NormalizeProviderKey(providerKey)); |
|
||||
} |
|
||||
|
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public override async Task SetAsync(FeatureDefinition feature, string value, string providerKey) |
|
||||
{ |
|
||||
if (IsHostSide(feature)) |
|
||||
{ |
|
||||
await Store.SetAsync(feature.Name, value, Name, NormalizeProviderKey(providerKey)); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public override async Task ClearAsync(FeatureDefinition feature, string providerKey) |
|
||||
{ |
|
||||
if (IsHostSide(feature)) |
|
||||
{ |
|
||||
await Store.DeleteAsync(feature.Name, Name, NormalizeProviderKey(providerKey)); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
protected override string NormalizeProviderKey(string providerKey) |
|
||||
{ |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
//TODO: Should throw an ex when there is not in the host side?
|
|
||||
protected virtual bool IsHostSide(FeatureDefinition feature) |
|
||||
{ |
|
||||
return feature.IsAvailableToHost && CurrentTenant.Id == null; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue