Evaluator<TSource> Class

Assembly: CodeEffects.Rule.Engine.dll
Namespace: CodeEffects.Rule.Engine

Summary

Provides core functionality for evaluating business rules when the exact type of the source object is known at design time.

Syntax

public class Evaluator<TSource> : CodeEffects.Rule.Engine.EvaluatorBase

Constructors

Methods

  • Evaluate(..)
    Returns: System.Boolean - Returns a Boolean value indicating the result of the rule evaluation: true if the evaluation succeeded; otherwise, false.

    Evaluates all rules in the ruleset within the defined scope against the specified source object.

    Parameters

    • source (TSource) - 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 (AND or OR) used when executing the rules in the ruleset.
    • shortCircuit (System.Boolean) - Specifies whether short-circuit evaluation is enabled. When set to true, the evaluator stops execution as soon as the rule scope is satisfied. When set to false, all rules are evaluated even if the final result is already determined. See Remarks in EvaluationParameters topic for details. The default value is true.
  • Evaluate(..)
    Returns: System.Boolean - Returns a Boolean value indicating the result of the rule evaluation: true if 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 (TSource) - 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 Boolean value indicating the result of the rule evaluation: true if 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 (TSource) - 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<TSource> - Returns a new System.Collections.Generic.IEnumerable<TSource> 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 Evaluator then 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.

    Type Parameters

    • TSource - An underlying source type of a generic enumerable collection.

    Parameters

    • source (System.Collections.IEnumerable<TSource>) - Specifies an enumerable collection of type System.Collections.Generic.IEnumerable<TSource> to be filtered.
  • Filter(..)
    Returns: System.Linq.IQueryable<TSource> - Returns an expression tree of type System.Linq.IQueryable<TSource> 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.

    Type Parameters

    • TSource - An underlying source type of a generic enumerable collection

    Parameters

    • source (System.Linq.IQueryable<TSource>) - Specifies a queryable collection of type System.Linq.IQueryable<TSource> to be filtered.

p101

l097 --

l102

p101

×