expression-evaluator-c-sharp icon indicating copy to clipboard operation
expression-evaluator-c-sharp copied to clipboard

Proposed enhancements for issue #7, based on work by MSpekkio

Open bwakabats opened this issue 1 year ago • 3 comments

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:

  1. 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.
  2. IFunctions must now be stateless (all existing internal IFunctions already are) since a single instance of each function is reused.

bwakabats avatar Aug 14 '23 21:08 bwakabats

@bwakabats nice work! @butulia @matheval can you please accept this PR and release a new nuget version?

jramoseguinoa avatar Nov 28 '23 02:11 jramoseguinoa

A wanted feature, is the one expected to be reviewed @butulia @matheval? Thanks for the effort :)

mikhail-teslya avatar May 22 '24 07:05 mikhail-teslya

@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

dei79 avatar May 31 '24 21:05 dei79