FormulaCompiler.cs 547 B

1234567891011121314151617
  1. using System;
  2. using FormulaEnginePoC.FormulaEngine;
  3. namespace FormulaEnginePoC.CSharpProvider
  4. {
  5. public class FormulaCompiler
  6. {
  7. public static Func<TSource, TResult> Compile<TSource, TResult>(string expression)
  8. {
  9. var exp = new ExpressionCompiler<Func<TSource, TResult>>(expression);
  10. exp.AddReferenceAssembly(typeof(MoreFunction).Assembly.Location);
  11. exp.AddNamespace(typeof(MoreFunction).Namespace);
  12. exp.Compile();
  13. return exp.CompiledDelegate;
  14. }
  15. }
  16. }