NCalcMEFed fork

Sep 20, 2010 at 3:47 PM

Firstly, a big thankyou to Sébastien Ros once again for creating NCalc & now for moving to mercurial.

I've created a fork "NCalcMEFed" which has the following changes i have made for my own use over the last few months - (fork is uptodate with latest changeset "389b5d7f4948" from 18/09/10):

  • Moved to Visual Studio 2010 and moved NCalc to .Net 4.0
  • Moved each function to it's own class implementing an AFunction abstract class
  • Documented each function and its parameters via a help system -TODO - this could be used for an intellisense like system - would love to see one if anyone has time/ know-how
  • Added functionality to print out language documentation.
  • Added Random function which works when used by multiple threads
  • Incorporated MEF (http://mef.codeplex.com) to dynamically load the functions in the library as well as to add extensibility
  • Added an ExpressionFactory.cs to manage MEF extensibility as well as have a way of creating expressions with identical parameters and evaluation options.
  • Added a utility routine within the factory to extract the variables from an expression
    • Added an Evaluation option "DebugMode" to support this by ensuring variables are extracted from both branches of an IF statement [ie both are evaluated]
  • Added an Evaluation Option "BuiltInFunctionsFirst" which should give a small speed improvement by first looking for functions already found via MEF before calling the EvaluateFunction event.
  • Improved the NCalc.Play example to show a few more examples of NCalc
  • Added 3 unit tests for new functionality [all previous ones pass :-) ]

I should probably say this code is provided as-is as this is my first open source submission [scary!] but i've been using this heavily in research projects for the last 6 months or so & it's been working well!

Please do let me know your thoughts on the fork or any questions on it's use [Much of the new functionality is demonstrated in the updated NCalc.Play]

David

May 9, 2012 at 3:11 PM

I attempted to create some custom functions in a different assembly and I ran into an issue.  The Evaluate method on EvaluationVisitor is internal so it can't be called outside of the NCalc assembly. 

May 24, 2012 at 2:11 PM

thanks for this, i'd changed the source on my machine but forgot to push to codeplex.

Hope the fork is useful?

 

David