expression-evaluator-c-sharp
expression-evaluator-c-sharp copied to clipboard
Proposed enhancements for issue #7, based on work by MSpekkio
Resolves issue #7 with the ability to register external function. Based on work by @MSpekkio in #9
The static Parser.RegisterFunction allows the registration of a type (derived from IFunction) or an instance of the same.
The functions can:
- Add new functions (demonstrated in the Unit Tests for "Custom_Function_Test > JOIN"
- Extend existing functions (demonstrated in "Custom_Function_Test > MID")
- Replace existing functions (demonstrated in "Custom_Function_Replacement_Test > ISBLANK")
NOTE: There are 2 changes to the underlying code:
- The name of the function is now derived from the FunctionDef.Name, rather than part of the IFunction class name. So a single IFunction could, in theory, accommodate more than one math function.
- IFunctions must now be stateless (all existing internal IFunctions already are) since a single instance of each function is reused.
@bwakabats nice work! @butulia @matheval can you please accept this PR and release a new nuget version?
A wanted feature, is the one expected to be reviewed @butulia @matheval? Thanks for the effort :)
@mikhail-teslya, @bwakabats and @jramoseguinoa I derived my own version of this awesome library and included the external functions capability. Just case you need this feature: https://github.com/dei79/ExpressionEvaluationRuntime