Show / Hide Table of Contents

Class ExceptionHandlingRuleLogicDecorator

A decorator class for the IValidationLogic interface which catches unhandled exceptions raised by the wrapped rule logic and instead returns a RuleResult with Errored.

Inheritance
System.Object
ExceptionHandlingRuleLogicDecorator
Implements
IValidationLogic
IHasRuleTimeout
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: CSF.Validation.Rules
Assembly: CSF.Validation.dll
Syntax
public class ExceptionHandlingRuleLogicDecorator : IValidationLogic, IHasRuleTimeout

Constructors

| Improve this Doc View Source

ExceptionHandlingRuleLogicDecorator(IValidationLogic)

Initialises an instance of ExceptionHandlingRuleLogicDecorator.

Declaration
public ExceptionHandlingRuleLogicDecorator(IValidationLogic wrapped)
Parameters
Type Name Description
IValidationLogic wrapped

The rule logic to be wrapped by the current instance.

Properties

| Improve this Doc View Source

RuleInterface

Gets the type of rule interface that is used by this rule logic.

Declaration
public Type RuleInterface { get; }
Property Value
Type Description
System.Type
Remarks

This will be a closed-generic form of either IRule<TValidated> or IRule<TValue, TParent>.

| Improve this Doc View Source

RuleObject

Gets a reference to the original/raw rule object instance.

Declaration
public object RuleObject { get; }
Property Value
Type Description
System.Object

Methods

| Improve this Doc View Source

GetResultAsync(Object, Object, RuleContext, CancellationToken)

Executes the logic of the validation rule and returns the result.

Declaration
public async ValueTask<RuleResult> GetResultAsync(object value, object parentValue, RuleContext context, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
System.Object value

The value which is being validated by the current rule.

System.Object parentValue

An optional 'parent value' to the value being validated by the current rule. This is typically the object from which the value is accessed.

RuleContext context

A validation rule context object.

System.Threading.CancellationToken token

An optional cancellation token to abort the validation process early.

Returns
Type Description
System.Threading.Tasks.ValueTask<RuleResult>

A task which provides the rule result.

| Improve this Doc View Source

GetTimeout()

Gets the timeout value for the current rule.

Declaration
public TimeSpan? GetTimeout()
Returns
Type Description
System.Nullable<System.TimeSpan>

A timespan indicating the timeout duration, or a null reference if no timeout is applicable.

Remarks

If this method returns non-null & the execution of the rule takes longer than this timeout value then:

The rule will immediately return an error result. Additionally the CancellationToken passed to the rule will be cancelled, allowing the rule logic to terminate early.

Implements

IValidationLogic
IHasRuleTimeout
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX