Giter Club home page Giter Club logo

eval-expression.net's Introduction

What's Eval Expression.NET?

Eval Expression.NET improves performance dramatically to access public and private methods, field, property value, or create object instances overusing C# reflection.

It allows you to evaluate, Compile and Execute dynamic 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, 2, 3, 4, 5 };
	var filter = list.Where(x => x < 4);
	return filter.Sum(x => x);");

Download

download

PM> Install-Package Z.Expressions.Eval

* PRO Version unlocked for the current month

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.Execute<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 supports all C# Syntax:

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

  • string interpolation
  • typename
  • null conditional member access

PRO

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

Features PRO Version
Maximum Characters Unlimited
Commercial License Yes
Royalty-Free Yes
Support & Upgrades (1 year) Yes
Learn more about the PRO Version
  • Starting from version 2.x, there is no longer a free limited version.
  • LINQ extension method is free with EF Classic - Community

Contribute

The best way to contribute is by spreading the word about the library:

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

A HUGE THANKS for your help.

More Projects

To view all our free and paid projects, visit our website.

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

eval-expression.net's People

Contributors

jonathanmagnan avatar stgelaisalex avatar lempireqc avatar mariloutb avatar waqasm78 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.