Skip to content

emmatb1/Eval-Expression.NET

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

174 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Evaluate, Compile and Execute C# code and expression at runtime##

From simple C# math expression...

int result = Eval.Execute<int>("X + Y", new { X = 1, Y = 2});

To complex code to parse.

int result = Eval.Execute<int>(@"
	var list = new List<int>() { 1..100 };
	var filter = list.Where(x => x < 3);
	return result.Sum(x => x);");

Eval Expression.NET improve dramatically performance to access public and private method, field, property value or to create object instance over using C# reflection.

Download

PM> Install-Package Z.Expressions.Eval

*FREE Version limited to 50 characters

Stay updated with latest changes

Twitter Follow Facebook Like

Eval.Execute

Evaluate and execute the code or expression.

Support:

Anonymous Class

// using Z.Expressions; // Don't forget to include this.
int result = Eval.Execute<int>("X + Y", new { X = 1, Y = 2});

Argument Position

// using Z.Expressions; // Don't forget to include this.
int result = Eval.Execute<int>("{0} + {1}", 1, 2);

Class Member

// using Z.Expressions; // Don't forget to include this.
dynamic expandoObject = new ExpandoObject();
expandoObject.X = 1;
expandoObject.Y = 2;
int result = Eval.Execute<int>("X + Y", expandoObject);

Extension Methods

// using Z.Expressions; // Don't forget to include this.
string s = "X + Y";
int result = s.Eval<int>(new { X = 1, Y = 2 });

Learn more

Eval.Compile

Compile the code or expression and return a delegate.

Support:

Custom Delegate

// using Z.Expressions; // Don't forget to include this.
var compiled = Eval.Compile<Func<int, int, int>>("X + Y", "X", "Y");
foreach(var item in list)
{
	int result = compiled(item.Value1, item.Value2);
}

Extension Methods

// using Z.Expressions; // Don't forget to include this.
string s = "X + Y";
var compiled = s.Compile<Func<int, int, int>>("X", "Y");
foreach(var item in list)
{
	int result = compiled(item.Value1, item.Value2);
}

Learn more

What's supported?

Eval Expression.NET support all C# Syntax:

You can even access to C# 6.0 features even if you are using C# 4.0.

  • string interpolation
  • typename
  • null conditional member access

Learn more

FREE vs PRO

Every month, a new monthly trial of the PRO Version is available to let you evaluate all its features without limitations.

Features FREE Version PRO Version
Maximum Characters 50 Unlimited
Commercial License No Yes
Royalty-Free No Yes
Support & Upgrades (1 year) No Yes
Learn more about the PRO Version

Contribution

Supporting & developing FREE features takes hundreds and thousands of hours! If you like our product please consider making a donation to keep us running.

Contribute

Contribution isn't all about money!

  • Blog it
  • Comment it
  • Fork it
  • Star it
  • Share it

A HUGE thanks for your extra support.

More Projects

Entity Framework

Bulk Operations

Expression Evaluator

Others

Need more info? info@zzzprojects.com

Contact our outstanding customer support for any request. We usually answer within the next business day, hour, or minutes!

About

C# Expression Evaluator | Evaluate, Compile and Execute C# code and expression at runtime.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 100.0%