Class RuleExecutionContext
An object which tracks which rules may be executed and which are still awaiting the execution of their dependencies. This may also be used to get a list of the rules which should not be executed because their dependencies failed.
Inheritance
Implements
Inherited Members
Namespace: CSF.Validation.RuleExecution
Assembly: CSF.Validation.dll
Syntax
public class RuleExecutionContext : IRuleExecutionContext
Remarks
Note that this is a stateful service, so it is not suitable to re-use instances outside of the context of a validation run. This object maintains and tracks the state of a validation operation throughout the context of that operation. For a new validation run, create a new instance of this service.
Constructors
| Improve this Doc View SourceRuleExecutionContext(IEnumerable<ExecutableRuleAndDependencies>)
Initialises a new instance of RuleExecutionContext.
Declaration
public RuleExecutionContext(IEnumerable<ExecutableRuleAndDependencies> allRules)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ExecutableRuleAndDependencies> | allRules | A collection of all of the rules which could be executed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
Properties
| Improve this Doc View SourceAllRules
Gets a read-only collection of all of the available validation rules and their dependencies.
Declaration
public IEnumerable<ExecutableRuleAndDependencies> AllRules { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ExecutableRuleAndDependencies> |
Methods
| Improve this Doc View SourceGetRulesWhichMayBeExecuted()
Gets a collection of rules which are ready to be executed. Either they have no dependencies or their dependencies have executed and passed.
Declaration
public IEnumerable<ExecutableRule> GetRulesWhichMayBeExecuted()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ExecutableRule> | A collection of rules that are ready to execute. |
GetRulesWhoseDependenciesHaveFailed()
Gets a collection of rules which should not be executed because their dependency rule(s) have failed.
Declaration
public IEnumerable<ExecutableRule> GetRulesWhoseDependenciesHaveFailed()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ExecutableRule> | A collection of rules which have failed dependencies. |
HandleValidationRuleResult(ExecutableRule)
Handles the alteration of dependency chains and available rules based upon a single validation rule receiving a result.
Declaration
public void HandleValidationRuleResult(ExecutableRule rule)
Parameters
Type | Name | Description |
---|---|---|
ExecutableRule | rule | The rule which now has a non-null Result property. |