Skip to content

Asynchronous Mathematical Expressions Evaluator for .NET

License

Notifications You must be signed in to change notification settings

lmorisse/ncalc-async

 
 

Repository files navigation

Build Status Nuget

NCalcAsync

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

API differences between NCalc and NCalcAsync

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.

About

Asynchronous Mathematical Expressions Evaluator for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 97.8%
  • GAP 2.1%
  • PowerShell 0.1%