Table of Contents

Class ExpressionBase<TExpressionContext>

Namespace
NCalc
Assembly
NCalc.Core.dll

Base class with common utilities of AST parsing and evaluation.

public abstract class ExpressionBase<TExpressionContext> where TExpressionContext : ExpressionContextBase, new()

Type Parameters

TExpressionContext
Inheritance
ExpressionBase<TExpressionContext>
Derived
Inherited Members

Constructors

ExpressionBase(LogicalExpression, TExpressionContext, ILogicalExpressionFactory, ILogicalExpressionCache)

protected ExpressionBase(LogicalExpression logicalExpression, TExpressionContext context, ILogicalExpressionFactory logicalExpressionFactory, ILogicalExpressionCache logicalExpressionCache)

Parameters

logicalExpression LogicalExpression
context TExpressionContext
logicalExpressionFactory ILogicalExpressionFactory
logicalExpressionCache ILogicalExpressionCache

ExpressionBase(string, TExpressionContext, ILogicalExpressionFactory, ILogicalExpressionCache)

protected ExpressionBase(string expressionString, TExpressionContext context, ILogicalExpressionFactory logicalExpressionFactory, ILogicalExpressionCache logicalExpressionCache)

Parameters

expressionString string
context TExpressionContext
logicalExpressionFactory ILogicalExpressionFactory
logicalExpressionCache ILogicalExpressionCache

ExpressionBase(TExpressionContext?)

protected ExpressionBase(TExpressionContext? context = null)

Parameters

context TExpressionContext

Properties

Context

protected TExpressionContext Context { get; }

Property Value

TExpressionContext

CultureInfo

Culture information for the expression evaluation.

public CultureInfo CultureInfo { get; set; }

Property Value

CultureInfo

Error

public Exception? Error { get; }

Property Value

Exception

ExpressionString

Textual representation of the expression.

public string? ExpressionString { get; protected init; }

Property Value

string

LogicalExpression

public LogicalExpression? LogicalExpression { get; protected set; }

Property Value

LogicalExpression

Options

Options for the expression evaluation.

public ExpressionOptions Options { get; set; }

Property Value

ExpressionOptions

Parameters

Parameters for the expression evaluation.

public IDictionary<string, object?> Parameters { get; set; }

Property Value

IDictionary<string, object>

Methods

GetFunctionNames()

Returns a list with all function names from the expression.

public List<string> GetFunctionNames()

Returns

List<string>

GetLogicalExpression()

protected LogicalExpression? GetLogicalExpression()

Returns

LogicalExpression

GetParameterNames()

Returns a list with all parameter names from the expression.

public List<string> GetParameterNames()

Returns

List<string>

HasErrors()

Create the LogicalExpression in order to check syntax errors. If errors are detected, the Error property contains the exception.

public bool HasErrors()

Returns

bool

True if the expression syntax is correct, otherwise False.