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.
50 lines
1.6 KiB
50 lines
1.6 KiB
using JetBrains.Annotations;
|
|
using Volo.Abp.SimpleStateChecking;
|
|
|
|
namespace Volo.Abp.Features;
|
|
|
|
public static class FeatureSimpleStateCheckerExtensions
|
|
{
|
|
public static TState RequireFeatures<TState>(
|
|
[NotNull] this TState state,
|
|
params string[] features)
|
|
where TState : IHasSimpleStateCheckers<TState>
|
|
{
|
|
state.RequireFeatures(requiresAll: true, batchCheck: true, features);
|
|
return state;
|
|
}
|
|
|
|
public static TState RequireFeatures<TState>(
|
|
[NotNull] this TState state,
|
|
bool requiresAll,
|
|
params string[] features)
|
|
where TState : IHasSimpleStateCheckers<TState>
|
|
{
|
|
state.RequireFeatures(requiresAll: requiresAll, batchCheck: true, features);
|
|
return state;
|
|
}
|
|
|
|
public static TState RequireFeatures<TState>(
|
|
[NotNull] this TState state,
|
|
bool requiresAll,
|
|
bool batchCheck,
|
|
params string[] features)
|
|
where TState : IHasSimpleStateCheckers<TState>
|
|
{
|
|
Check.NotNull(state, nameof(state));
|
|
Check.NotNullOrEmpty(features, nameof(features));
|
|
|
|
if (batchCheck)
|
|
{
|
|
RequireFeaturesSimpleBatchStateChecker<TState>.Current.AddCheckModels(
|
|
new RequireFeaturesSimpleBatchStateCheckerModel<TState>(state, features, requiresAll));
|
|
state.StateCheckers.Add(RequireFeaturesSimpleBatchStateChecker<TState>.Current);
|
|
}
|
|
else
|
|
{
|
|
state.StateCheckers.Add(new RequireFeaturesSimpleStateChecker<TState>(requiresAll, features));
|
|
}
|
|
|
|
return state;
|
|
}
|
|
}
|
|
|