Interface IMutationPolicy<TState>
Represents policy that decides whether a mutation can be applied. Policies are FIRST CLASS governance mechanism in the mutation framework.
Namespace: ModularityKit.Mutator.Abstractions.Policies
Assembly: ModularityKit.Mutator.dll
Syntax
public interface IMutationPolicy<TState>
Type Parameters
| Name | Description |
|---|---|
| TState | Type of the state the mutation operates on. |
Properties
| Edit this page View SourceDescription
Optional description of the policy.
Declaration
string? Description { get; }
Property Value
| Type | Description |
|---|---|
| string |
Name
The name of the policy.
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Priority
Priority of the policy evaluation. Higher values are evaluated earlier.
Declaration
int Priority { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceEvaluate(IMutation<TState>, TState)
Evaluates whether the given mutation is allowed on the current state.
Declaration
PolicyDecision Evaluate(IMutation<TState> mutation, TState state)
Parameters
| Type | Name | Description |
|---|---|---|
| IMutation<TState> | mutation | The mutation to evaluate. |
| TState | state | The current state before applying the mutation. |
Returns
| Type | Description |
|---|---|
| PolicyDecision | A PolicyDecision representing the result of the evaluation. |
EvaluateAsync(IMutation<TState>, TState, CancellationToken)
Evaluates whether the given mutation is allowed on the current state asynchronously.
Declaration
Task<PolicyDecision> EvaluateAsync(IMutation<TState> mutation, TState state, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IMutation<TState> | mutation | The mutation to evaluate. |
| TState | state | The current state before applying the mutation. |
| CancellationToken | cancellationToken | Token used to cancel the policy evaluation. |
Returns
| Type | Description |
|---|---|
| Task<PolicyDecision> | A PolicyDecision representing the result of the evaluation. |