NCalcAsync is a fully async port of the NCalc mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions.
For general documentation refer to the NCalc wiki:
- description: overall concepts, usage and extensibility points
- operators: available standard operators and structures
- values: authorized values like types, functions, ...
- functions: list of already implemented functions
- parameters: on how to use parameters expressions
Expressions are evaluated using Expression.EvaluateAsync()
instead of Expression.Evaluate()
.
Async custom parameter and function handlers are assigned to Expression.EvaluateParameterAsync
and Expression.EvalauteFunctionAsync
, instead of adding event handlers. They are asynchronous
and thus return a Task
but otherwise behave the same way as the handlers in NCalc, i.e. they set
args.Result
to pass back the result and indicate that it handled the symbol. Multiple handlers
can be added with +=
, just like in NCalc. They are awaited in order, so if one of them blocks
the following handlers will not be called until it returns.
FunctionArgs.EvaluateParametersAsync()
replaces FunctionArgs.EvaluateParameters()
.
Custom LogicalExpressionVisitor
implementations must be fully asynchronous.
The custom LogicalExpression.ToString()
is removed.