C# Class HandCoded.Validation.RuleSet

A RuleSet instance contains a collection of validation rules that can be tested against a XmlDocument in a single operation.
Inheritance: Validator
Exibir arquivo Open project: formicary/fpml-toolkit-csharp Class Usage Examples

Public Methods

Method Description
Add ( Rule rule ) : void

Adds the indicated Rule instance to the RuleSet A Rule may be referenced by several RuleSet instances simultaneously.

If the Rule has the same name as a previously added one then it will replace it. This feature can be used to overwrite standard rules with customized ones.

Add ( RuleSet ruleSet ) : void

Adds the Rule instances that comprise another RuleSet to this one.

ForName ( string name ) : RuleSet

Returns a reference to the named RuleSet instance if it exists.

Remove ( Rule rule ) : Rule

Attempts to remove a given Rule from the collection held by the RuleSet.

Remove ( string name ) : Rule

Attempts to remove a Rule with the given name from the collection held by the RuleSet.

RuleSet ( string name ) : System

Constructs a named empty RuleSet.

Protected Methods

Method Description
Validate ( NodeIndex nodeIndex, ValidationErrorHandler errorHandler ) : bool

Determines if the XmlDocument instance indexed by the provided NodeIndex has business data content that passes a validation test. If errors are detected they will be reported through the ValidationErrorHandler delegate passed as an argument.

Note that test returns true if it does not fail, including circumstances when the test is inapplicable to the XmlDocument under examination.

Private Methods

Method Description
ParseRuleSets ( string uri ) : void

Parse the RuleSet definitions in the configuration file indicated by the URI.

RuleSet ( ) : System

Causes the RuleSet class to try and bootstrap the business rules from a configuration file.

Method Details

Add() public method

Adds the indicated Rule instance to the RuleSet A Rule may be referenced by several RuleSet instances simultaneously.

If the Rule has the same name as a previously added one then it will replace it. This feature can be used to overwrite standard rules with customized ones.

public Add ( Rule rule ) : void
rule Rule The to be added.
return void

Add() public method

Adds the Rule instances that comprise another RuleSet to this one.
public Add ( RuleSet ruleSet ) : void
ruleSet RuleSet The RuleSet to be added.
return void

ForName() public static method

Returns a reference to the named RuleSet instance if it exists.
public static ForName ( string name ) : RuleSet
name string The name of the required RuleSet.
return RuleSet

Remove() public method

Attempts to remove a given Rule from the collection held by the RuleSet.
public Remove ( Rule rule ) : Rule
rule Rule The to be removed.
return Rule

Remove() public method

Attempts to remove a Rule with the given name from the collection held by the RuleSet.
public Remove ( string name ) : Rule
name string The name of the to be removed.
return Rule

RuleSet() public method

Constructs a named empty RuleSet.
public RuleSet ( string name ) : System
name string
return System

Validate() protected method

Determines if the XmlDocument instance indexed by the provided NodeIndex has business data content that passes a validation test. If errors are detected they will be reported through the ValidationErrorHandler delegate passed as an argument.
Note that test returns true if it does not fail, including circumstances when the test is inapplicable to the XmlDocument under examination.
protected Validate ( NodeIndex nodeIndex, ValidationErrorHandler errorHandler ) : bool
nodeIndex HandCoded.Xml.NodeIndex The instance to examine.
errorHandler ValidationErrorHandler An delegate used to report /// validation failures.
return bool