Skip to content

This is a lib for parsing code in runtime. The program language is C#.

License

Notifications You must be signed in to change notification settings

pizzo00/lambda-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 

Repository files navigation

Lambda Parser

This is a lib for parsing code in runtime. The program language is C#.

Example1 - string concat and number calculate:

string code = "2.ToString()+(4*2)"; // C# code
Func<string> func = ExpressionParser.Compile<Func<string>>(code); // compile code
string result = func(); // result = "28"

Example2 - input parameter:

Delegate dele = ExpressionParser.Compile("(int m)=>-m");
var result = (int)dele.DynamicInvoke(10); // result = -10

Example3 - access property in anonymous type:

//using Zhucai.LambdaParser.ObjectDynamicExtension;
object obj = new { Name = "zhangsan", Id = 18 }; // maybe get [obj] from method return value
int result = obj.E<int>("Id"); // result = 18

You can view test code to explore more functions.

About

This is a lib for parsing code in runtime. The program language is C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%