Table of Contents

Class EvaluationHelper

Namespace
NCalc.Helpers
Assembly
NCalc.Core.dll

Provides helper methods for evaluating expressions.

public static class EvaluationHelper
Inheritance
EvaluationHelper
Inherited Members

Methods

Div(object?, object?, ExpressionContext)

public static object? Div(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object
rightValue object
context ExpressionContext

Returns

object

In(object?, object?, ExpressionContext)

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, ExpressionContext context)

Parameters

rightValue object

The right operand.

leftValue object

The left operand.

context ExpressionContext

The 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?, ExpressionContext)

Determines whether a specified string matches a pattern using SQL-like wildcards.

public static bool Like(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object

The left operand.

rightValue object

The right operand.

context ExpressionContext

The context containing options for the comparison.

Returns

bool

true if the value matches the pattern; otherwise, false.

Remarks

The comparison is case-insensitive if the CaseInsensitiveStringComparer flag is set in the context.

Minus(object?, object?, ExpressionContext)

public static object? Minus(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object
rightValue object
context ExpressionContext

Returns

object

Modulo(object?, object?, ExpressionContext)

public static object? Modulo(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object
rightValue object
context ExpressionContext

Returns

object

Plus(object?, object?, ExpressionContext)

Adds two values, with special handling for string concatenation based on the context options.

public static object? Plus(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object

The left operand.

rightValue object

The right operand.

context ExpressionContext

The evaluation context.

Returns

object

The result of the addition or string concatenation.

Times(object?, object?, ExpressionContext)

public static object? Times(object? leftValue, object? rightValue, ExpressionContext context)

Parameters

leftValue object
rightValue object
context ExpressionContext

Returns

object

Unary(UnaryExpression, object?, ExpressionContext)

Evaluates a unary expression.

public static object? Unary(UnaryExpression expression, object? result, ExpressionContext context)

Parameters

expression UnaryExpression

The unary expression to evaluate.

result object

The result of evaluating the operand of the unary expression.

context ExpressionContext

The evaluation context.

Returns

object

The result of the unary operation.

Exceptions

InvalidOperationException

Thrown when the unary expression type is unknown.