Class EvaluationHelper<TExpressionContext>
Provides helper methods for evaluating expressions.
public static class EvaluationHelper<TExpressionContext> where TExpressionContext : ExpressionContextBase
Type Parameters
TExpressionContext
- Inheritance
-
EvaluationHelper<TExpressionContext>
- Inherited Members
Methods
In(object?, object?, TExpressionContext)
Determines if the left value is contained within the right value, which must be either an enumerable or a string.
public static bool In(object? rightValue, object? leftValue, TExpressionContext context)
Parameters
rightValueobjectThe right operand.
leftValueobjectThe left operand.
contextTExpressionContextThe evaluation context.
Returns
- bool
True if the left value is contained within the right value, otherwise false.
Exceptions
- NCalcEvaluationException
Thrown when the right value is not an enumerable or a string.
Like(object?, object?, TExpressionContext)
Determines whether a specified string matches a pattern using SQL-like wildcards.
public static bool Like(object? leftValue, object? rightValue, TExpressionContext context)
Parameters
leftValueobjectThe left operand.
rightValueobjectThe right operand.
contextTExpressionContextThe context containing options for the comparison.
Returns
- bool
trueif thevaluematches thepattern; otherwise,false.
Remarks
The comparison is case-insensitive if the CaseInsensitiveStringComparer flag is set in the context.
Plus(object?, object?, TExpressionContext)
Adds two values, with special handling for string concatenation based on the context options.
public static object? Plus(object? leftValue, object? rightValue, TExpressionContext context)
Parameters
leftValueobjectThe left operand.
rightValueobjectThe right operand.
contextTExpressionContextThe evaluation context.
Returns
- object
The result of the addition or string concatenation.
Unary(UnaryExpression, object?, TExpressionContext)
Evaluates a unary expression.
public static object? Unary(UnaryExpression expression, object? result, TExpressionContext context)
Parameters
expressionUnaryExpressionThe unary expression to evaluate.
resultobjectThe result of evaluating the operand of the unary expression.
contextTExpressionContextThe evaluation context.
Returns
- object
The result of the unary operation.
Exceptions
- InvalidOperationException
Thrown when the unary expression type is unknown.