How can I convert this into expression tree or using linq so I can write function base on these expression hierarchy?.
I have seen this library but I am not sure I am on right path to https://csharpeval.codeplex.com/wikipage?title=Usage&referringTitle=Documentation
max(avg(high1:3),avg(low1:3)) - min(avg(high1:3),avg(low1:3))
Compiling and executing codes at run time is always a bit challenging. The library that you mentioned is just a way.
You can use Roslyn which comes with C# 6.0 and Visual Studio 2015 by Microsoft and the C# team. You can't imagine how powerful is it. Here are some samples and walkthroughs:
https://github.com/dotnet/roslyn/wiki/Samples-and-Walkthroughs
And some other introductions:
https://en.wikipedia.org/wiki/.NET_Compiler_Platform
And here is some sample to create a REPL (something like what you want):
http://www.jayway.com/2015/05/09/using-roslyn-to-build-a-simple-c-interactive-script-engine/
Using Roslyn can simple have something like this:
var csScript =
string.Format(@"
var x = Math.Max(Math.Avg({0},3),Math.Avg(low1:3));
x;
", high1, low1);
//And this from the REPL
Console.WriteLine(CSharpScriptEngine.Execute(csScript));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.