|
|
|
|
@ -3,10 +3,10 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
|
using Volo.Abp.Features;
|
|
|
|
|
using Volo.Abp.Validation;
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement
|
|
|
|
|
{
|
|
|
|
|
@ -15,15 +15,18 @@ namespace Volo.Abp.FeatureManagement
|
|
|
|
|
protected IFeatureDefinitionManager FeatureDefinitionManager { get; }
|
|
|
|
|
protected List<IFeatureManagementProvider> Providers => _lazyProviders.Value;
|
|
|
|
|
protected FeatureManagementOptions Options { get; }
|
|
|
|
|
protected IStringLocalizerFactory StringLocalizerFactory { get; }
|
|
|
|
|
|
|
|
|
|
private readonly Lazy<List<IFeatureManagementProvider>> _lazyProviders;
|
|
|
|
|
|
|
|
|
|
public FeatureManager(
|
|
|
|
|
IOptions<FeatureManagementOptions> options,
|
|
|
|
|
IServiceProvider serviceProvider,
|
|
|
|
|
IFeatureDefinitionManager featureDefinitionManager)
|
|
|
|
|
IFeatureDefinitionManager featureDefinitionManager,
|
|
|
|
|
IStringLocalizerFactory stringLocalizerFactory)
|
|
|
|
|
{
|
|
|
|
|
FeatureDefinitionManager = featureDefinitionManager;
|
|
|
|
|
StringLocalizerFactory = stringLocalizerFactory;
|
|
|
|
|
Options = options.Value;
|
|
|
|
|
|
|
|
|
|
//TODO: Instead, use IHybridServiceScopeFactory and create a scope..?
|
|
|
|
|
@ -131,9 +134,9 @@ namespace Volo.Abp.FeatureManagement
|
|
|
|
|
|
|
|
|
|
var feature = FeatureDefinitionManager.Get(name);
|
|
|
|
|
|
|
|
|
|
if (feature.ValueType.Validator != null && !feature.ValueType.Validator.IsValid(value))
|
|
|
|
|
if (!feature.ValueType.Validator.IsValid(value))
|
|
|
|
|
{
|
|
|
|
|
throw new BusinessException($"{feature.Name} value is invalid");
|
|
|
|
|
throw new FeatureValueInvalidException(feature.DisplayName.Localize(StringLocalizerFactory));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var providers = Enumerable
|
|
|
|
|
|