top of page

What is ExpressionEval ?

ExpressionEval is an Expression Evaluator back-office component. Expression are provided as raw string. It enables you to evaluate easily: logical (Or, And and Not), comparison (=, <>, <=, <, >, >=) or calculation (+, -, *, /) in an application. Possible to use variable and function call. The component is configurable: double decimal separator, string tag,... This component is a library provided in .NET Standard 2.0 and in .NET Framework 4.5.

Key features

-Input expression as a raw string,

The expression can be simple or complex,

-Can have nested expression, one or more,

-Comparison operator possible: Or, And, Not,

-Comparison operator can be defined in english (Or, And, Not) or in french (Ou, Et, Non),

-Logical operator possible: =, <>, >, <, >=, <=,

-Calculation operator managed: +, -, * /,

-Value type managed: string, int, double, bool,

-Predefined boolean value can be used: true/False (in english) vrai/faux (in french),-V,

-You can use variable, one or more,

-You can use function call,

-Wrong expression error management.

​

​

Getting started ?

Here is a basic general sample which demonstrate how to use the component.

​

1/ you provide your expression to the engine as a simple string, for example:
"(a=b) and (c>12)"

​

2/ The engine parse the expression

​

3/ you have to define and set all used variables present in the expression:
a=12
b=12
c=15

​

4/Then the engine execute the expression using the variables values and return the result:

true!
 

The source code:

​

Using clauses:

using Pierlam.ExpressionEval;

​

Create the component:

ExpressionEval evaluator = new ExpressionEval();

​

1/ Create the expression to use:

string expr= "(a=b) and (c>12)";

​

2/ Parse, Decode the expression:

evaluator.Parse(expr);

​

3/ Create variable and provide values:

evaluator.DefineVarInt("a", 12);

evaluator.DefineVarInt("b", 12);

evaluator.DefineVarInt("a", 15);

​

4/ Execute the expression:

ExprExecResult exprExecResult= evaluator.Exec();

Ex

Get the result and display it:

Console.WriteLine("Execution Result: " + exprExecResult.ResultBool);

Display

--Console output:

Execution Result: true

​

​

Get the library

The last available version is: 0.5.

The library is provided in two target: .NET Standard 2.0 and .NET 4.5

​

​

You can get the packet from nuget here: nuget.org/packages/Pierlam.ExpressionEval

​

Source Code samples

You can find some code samples in a Visual Studio solution here: 

https://github.com/Pierlam-Project/ExpressionEvalSamples 

​

Examples of expressions

Here are some examples of expressions you can execute :

(a = b)

not(a)

not a

(a and b)

(a and b) or (c >= d)

not(a and b)

(a+b)*c

...

​

Contact us

Need Help? Question to ask?

Feel free to contact us : Pierlam-Project@outlook.com

In English or in French.

​

​

​

bottom of page