-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathFeatureSimpleStateCheckerExtensions.cs
More file actions
50 lines (44 loc) · 1.56 KB
/
FeatureSimpleStateCheckerExtensions.cs
File metadata and controls
50 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
}
}