EvaluationParameters Class
Assembly: CodeEffects.Rule.Common.dll
Namespace: CodeEffects.Rule.Common.Models
Summary
Represents a parameter object used by the rule evaluator classes during rule evaluation.
Syntax
public class EvaluationParameters
Properties
LINQProviderType
Type: CodeEffects.Rule.Common.Models.LinqProviderType
Gets or sets the type of LINQ provider used when Code Effects builds expression trees during data filtering operations. The Default
value indicates that the engine will attempt to detect the LINQ provider type automatically. Use SQL
for LINQ-to-SQL providers and Entities
for LINQ-to-Entities. This enumeration exists because various providers handle string operations differently, and in most cases it is difficult to automatically determine the behavior of the current provider. Theoretically, any LINQ provider is supported as long as it implements the same set of commands as LINQ-to-SQL.
MaxIterations
Type: System.Int32
Gets or sets the maximum number of iterations allowed before the evaluation fails in Loop mode. A value of -1
indicates no limit.
MidpointRounding
Type: System.MidpointRounding
Gets or sets the rounding algorithm. The default value is System.MidpointRounding.ToEven
, also known as round to even or banker’s rounding. This is the default .NET rounding algorithm. For traditional rounding, set this property to MidpointRounding.AwayFromZero
.
PerformNullChecks
Type: System.Boolean
Gets or sets a value indicating whether the engine includes null-pointer safety checks in the compiled code to prevent run-time exceptions. The default value is true
.
Precision
Type: System.Int32
Gets or sets the number of fractional digits to which decimal or double values are rounded. Rounding is applied only in comparison operators using the Math.Round()
method. A value of -1
disables rounding.
PreserveWhitespace
Type: System.Boolean
Gets or sets a value indicating whether the rule editor preserves white spaces in string values in the Rule XML during rule generation. By default, the rule editor trims all string values and reduces consecutive white spaces to a single space. For example, if this property is set to false
, the string value " My name is John " is saved in the Rule XML as "My name is John". The default value is false
.
RuleGetter
Type: CodeEffects.Rule.Core.GetRuleDelegate
Delegate used to request missing rules — rules that are referenced but not included in the current rule set. This property is optional.
RuleId
Type: System.String
Gets or sets the ID of the rule to be evaluated or compiled. This property is optional.
Scope
Type: CodeEffects.Rule.Core.EvaluationScope
Gets or sets a value that specifies how to treat multiple rules in a rule set when they are evaluated in a single step using the Ruleset mode. The default value is EvaluationScope.All
. See Remarks for additional details.
ShortCircuit
Type: System.Boolean
Gets or sets a value indicating whether to stop further evaluation of a rule immediately after its result has been determined. The default value is true
. See Remarks for additional details.
Remarks
The ShortCircuit
parameter applies only to entire rules, not to individual statements, and operates in conjunction with the Scope
parameter.
To illustrate, consider a ruleset containing three rules — A
, B
, and C
. The following table demonstrates the possible evaluation states:
Scope |
ShortCircuit |
Expression |
Details |
All |
True |
A short-and B short-and C |
Rules are evaluated sequentially using the logical `AND` operator. The evaluation process stops immediately when any rule returns `false`. |
All |
False |
A and B and C |
All rules are evaluated, and their results are combined using the logical `AND` operator. |
AtLeastOne |
True |
A short-or B short-or C |
Rules are evaluated sequentially using the logical `OR` operator. The evaluation process stops immediately when any rule returns `true`. |
AtLeastOne |
False |
A or B or C |
All rules are evaluated, and their results are combined using the logical `OR` operator. |
Individual rules are still evaluated using short-circuit logic internally.
This behavior applies in two scenarios:
- When evaluating multiple rules as part of a larger ruleset — call the
Evaluator.Evaluate(TSource, EvaluationScope, bool)
overload.
- When evaluating a single rule that contains multiple
if
statements in Ruleset mode — pass the desired settings in the EvaluationParameters
param of the Evaluator
constructor.