Evaluator Class
Assembly: CodeEffects.Rule.Engine.dll
Namespace: CodeEffects.Rule.Engine
Summary
Provides core functionality for the evaluation of business rules when the exact type of the source object is known only at run time.
Syntax
public class Evaluator : CodeEffects.Rule.Engine.EvaluatorBase
Constructors
- Evaluator(..) - Parameters
- Evaluator(..) - Parameters
- Evaluator(..) - Parameters- 
- 
- sourceType (System.Type) - The type of the source object used by all rules referenced in the Rule XML of the ruleset being evaluated.
- rulesetXml (System.String) - The Rule XML document as a string.
- getRule (CodeEffects.Rule.Common.Models.GetRuleDelegate) - Specifies a delegate to a method used for retrieving external rules referenced by other rules. If this parameter isnull, the evaluator attempts to locate any referenced rules within the ruleset itself. If no referenced rules are found, an exception is thrown.
- maxIterations (System.Int32) - The maximum number of rule iterations in the Loop mode of the Rule Editor. The default value is-1, which means no limit.
 
 
Properties
Methods
- Evaluate(..)
 Returns:- System.Boolean- Returns a- Booleanvalue indicating the result of the rule evaluation:- trueif the evaluation succeeded; otherwise,- false.
 - 
- Evaluates all rules in the ruleset within the defined scope against the specified source object. 
 - Parameters- 
- 
- source (System.Object) - Specifies the object to be evaluated. This object serves as the data source for the rule.
- scope (CodeEffects.Rule.Common.Models.EvaluationScope) - Specifies the logical operator (ANDorOR) used when executing the rules in the ruleset.
- shortCircuit (System.Boolean) - Specifies whether short-circuit evaluation is enabled. When set totrue, the evaluator stops execution as soon as the rule scope is satisfied. When set tofalse, all rules are evaluated even if the final result is already determined. See Remarks inEvaluationParameterstopic for details. The default value istrue.
 
 
- Evaluate(..)
 Returns:- System.Boolean- Returns a- Booleanvalue indicating the result of the rule evaluation:- trueif the evaluation succeeded; otherwise,- false.
 - 
- Evaluates the specific rule selected by its zero-based index from the ruleset against the specified source object. 
 - Parameters- 
- 
- source (System.Object) - Specifies the object to be evaluated. This object serves as the data source for the rule.
- ruleIndex (System.Int32) - Specifies the index of the rule to be executed. If the ruleset contains multiple rules, you can evaluate a specific rule by providing its index. Do not confuse this with external rules referenced within other rules. The specified rule must exist as a top-level rule within the ruleset; otherwise, an exception will be thrown.
 
 
- Evaluate(..)
 Returns:- System.Boolean- Returns a- Booleanvalue indicating the result of the rule evaluation:- trueif the evaluation succeeded; otherwise,- false.
 - 
- Evaluates the rule against the specified source object. If no rule ID is provided, the first rule in the ruleset is evaluated by default. 
 - Parameters- 
- 
- source (System.Object) - Specifies the object to be evaluated. This object serves as the data source for the rule.
- ruleId (System.String) - Specifies an optional ID of the rule to be evaluated. If the ruleset contains multiple rules, you can evaluate a specific rule by providing its ID. Do not confuse this with external rules referenced within other rules. The specified rule must exist as a top-level rule within the ruleset; otherwise, an exception will be thrown.
 
 
- Filter(..)
 Returns:- System.Collections.IEnumerable- Returns a new- System.Collections.Generic.IEnumerable<T>collection containing all source objects that satisfied the rule evaluation.
 - 
- Filters a collection of source objects by applying a business rule. The specified ruleset Xml is loaded into the - Evaluator, where its rules are compiled into IL objects and stored in memory. The- Evaluatorthen applies the rule to each object in the collection. Source objects that satisfy the rule are returned as a new collection of type- System.Collections.IEnumerable.
 
 - Parameters- 
- 
- source (System.Collections.IEnumerable) - Specifies an enumerable collection of typeSystem.Collections.Generic.IEnumerable<T>to be filtered.
 
 
- Filter(..)
 Returns:- System.Linq.IQueryable- Returns an expression tree of type- System.Linq.IQueryable<T>for deferred or immediate evaluation. Immediate evaluation is performed by the underlying LINQ provider.
 - 
- Filters a collection of source objects by applying a business rule. The specified ruleset Xml is loaded into the - Evaluator, where its rules are compiled into expression trees. This method does not perform immediate evaluation; instead, it returns an expression tree that can be further modified. During execution, the expression tree is translated into a set of backend commands supported by the underlying LINQ provider. For example, when using LINQ to SQL, the expression tree is translated into corresponding SQL commands.
 
 - Parameters- 
- 
- source (System.Linq.IQueryable) - Specifies a queryable collection of typeSystem.Linq.IQueryable<T>to be filtered.