|
|
|
|
@ -1,25 +1,25 @@
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.GlobalFeatures
|
|
|
|
|
{
|
|
|
|
|
public abstract class GlobalFeatureManagerModuleConfigurator
|
|
|
|
|
public abstract class GlobalModuleFeatures
|
|
|
|
|
{
|
|
|
|
|
[NotNull]
|
|
|
|
|
public GlobalFeatureManagerModulesConfigurator ModulesConfigurator { get; }
|
|
|
|
|
public GlobalFeatureConfiguratorDictionary AllFeatures { get; }
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
public ConcurrentDictionary<string, GlobalFeature> Features { get; }
|
|
|
|
|
public GlobalFeatureManager FeatureManager { get; }
|
|
|
|
|
|
|
|
|
|
protected GlobalFeatureManagerModuleConfigurator(GlobalFeatureManagerModulesConfigurator modulesConfigurator)
|
|
|
|
|
protected GlobalModuleFeatures(
|
|
|
|
|
GlobalFeatureManager featureManager)
|
|
|
|
|
{
|
|
|
|
|
ModulesConfigurator = Check.NotNull(modulesConfigurator, nameof(modulesConfigurator));
|
|
|
|
|
Features = new ConcurrentDictionary<string, GlobalFeature>();
|
|
|
|
|
AllFeatures = new GlobalFeatureConfiguratorDictionary();
|
|
|
|
|
FeatureManager = featureManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void EnableAll()
|
|
|
|
|
{
|
|
|
|
|
foreach (var feature in Features.Values)
|
|
|
|
|
foreach (var feature in AllFeatures.Values)
|
|
|
|
|
{
|
|
|
|
|
feature.Enable();
|
|
|
|
|
}
|
|
|
|
|
@ -27,10 +27,31 @@ namespace Volo.Abp.GlobalFeatures
|
|
|
|
|
|
|
|
|
|
public virtual void DisableAll()
|
|
|
|
|
{
|
|
|
|
|
foreach (var feature in Features.Values)
|
|
|
|
|
foreach (var feature in AllFeatures.Values)
|
|
|
|
|
{
|
|
|
|
|
feature.Disable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void AddFeature(string featureName)
|
|
|
|
|
{
|
|
|
|
|
AddFeature(new GlobalFeature(this, featureName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void AddFeature(GlobalFeature feature)
|
|
|
|
|
{
|
|
|
|
|
AllFeatures[feature.FeatureName] = feature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected GlobalFeature GetFeature(string featureName)
|
|
|
|
|
{
|
|
|
|
|
return AllFeatures[featureName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected TFeature GetFeature<TFeature>(string featureName)
|
|
|
|
|
where TFeature : GlobalFeature
|
|
|
|
|
{
|
|
|
|
|
return (TFeature) AllFeatures[featureName];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|