mirror of https://github.com/abpframework/abp.git
6 changed files with 100 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Features; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
//TODO: Implement caching
|
||||
|
|
||||
|
public class FeatureStore : IFeatureStore, ITransientDependency |
||||
|
{ |
||||
|
protected IFeatureValueRepository FeatureValueRepository { get; } |
||||
|
|
||||
|
public FeatureStore(IFeatureValueRepository featureValueRepository) |
||||
|
{ |
||||
|
FeatureValueRepository = featureValueRepository; |
||||
|
} |
||||
|
|
||||
|
public async Task<string> GetOrNullAsync( |
||||
|
string name, |
||||
|
string providerName, |
||||
|
string providerKey) |
||||
|
{ |
||||
|
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); |
||||
|
return featureValue?.Value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
public class FeatureValue : Entity<Guid>, IAggregateRoot<Guid> |
||||
|
{ |
||||
|
[NotNull] |
||||
|
public virtual string Name { get; protected set; } |
||||
|
|
||||
|
[NotNull] |
||||
|
public virtual string Value { get; internal set; } |
||||
|
|
||||
|
[NotNull] |
||||
|
public virtual string ProviderName { get; protected set; } |
||||
|
|
||||
|
[CanBeNull] |
||||
|
public virtual string ProviderKey { get; protected set; } |
||||
|
|
||||
|
protected FeatureValue() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public FeatureValue( |
||||
|
Guid id, |
||||
|
[NotNull] string name, |
||||
|
[NotNull] string value, |
||||
|
[NotNull] string providerName, |
||||
|
[CanBeNull] string providerKey) |
||||
|
{ |
||||
|
Check.NotNull(name, nameof(name)); |
||||
|
|
||||
|
Id = id; |
||||
|
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
||||
|
Value = Check.NotNullOrWhiteSpace(value, nameof(value)); |
||||
|
ProviderName = Check.NotNullOrWhiteSpace(providerName, nameof(providerName)); |
||||
|
ProviderKey = providerKey; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
public static class FeatureValueConsts |
||||
|
{ |
||||
|
public const int MaxNameLength = 128; |
||||
|
|
||||
|
public const int MaxProviderNameLength = 64; |
||||
|
|
||||
|
public const int MaxProviderKeyLength = 64; |
||||
|
|
||||
|
public const int MaxValueLength = 128; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
public interface IFeatureValueRepository : IBasicRepository<FeatureValue, Guid> |
||||
|
{ |
||||
|
Task<FeatureValue> FindAsync(string name, string providerName, string providerKey); |
||||
|
|
||||
|
Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue