ExpressionCalculator

Implements an expression calculator.

Description

The ExpressionCalculator class allows you to create an expression calculator.

Constructors

Constructs this class with default parameters.

public ExpressionCalculator()

Constructs this class and assigns a expression string.

public ExpressionCalculator(string expression)

  • expression: string - expression string.

Properties

AutoVariables

Gets and Sets the flag to turn on auto-creation of variables for a specified expression.

public Boolean AutoVariables { get; set; }

defaultFunctions

List with default functions.

public IFunctionCollection DefaultFunctions { get; }

DefaultVariables

List with default variables.

public IVariableCollection DefaultVariables

Expression

Expression string.

public string Expression { get; set; }

InitialTokens

List of original expression tokens.

public IList<ExpressionToken> InitialTokens { get; }

OriginalTokens

List of expression tokens.

public IList<Token> OriginalTokens { get; set; }

ResultTokens

List of processed expression tokens.

public IList<ExpressionToken> ResultTokens { get; }

VariantOperations

Gets and sets the manager for operations on variant values.

public IVariantOperations VariantOperations { get; set; }

Instance methods

Clear

Cleans up this calculator from all data.

public void Clear()

CreateVariables

Cleans up this calculator from all data.

public void CreateVariables(IVariantOperations variables)

Evaluate

Evaluates this expression using default variables and functions.

public Task<Variant> EvaluateAsync()

  • returns: Task<Variant> - evaluation result.

EvaluateUsingVariablesAsync

Evaluates this expression using specified variables.

public Task<Variant> EvaluateUsingVariablesAsync(IVariantOperations variables)

EvaluateUsingVariablesAndFunctionsAsync

Evaluates this expression using specified variables and functions.

public Task<Variant> EvaluateUsingVariablesAndFunctionsAsync(IVariantOperations variables, IFunctionCollection functions)