Skip to content

Releases: datchung/ExpressionEvaluator

Bug Fix

27 May 14:21
Compare
Choose a tag to compare
  • Fix bug for operator mapping not replacing "!abc" to "NOT abc" when there is no preceding white space

Operator Mapping

14 May 03:08
Compare
Choose a tag to compare

Support operator mapping.

Example:

ExpressionEvaluator.SetOperatorMap(new Dictionary<string, string>
{
    {"+", "plus"},
    {"*", "times"},
    {"/", "divideBy"},
});

// Returns 6
int result = ExpressionEvaluator.Evaluate<int>("(1 plus 2) times 2");

Initial Release

07 May 02:32
Compare
Choose a tag to compare

ExpressionEvaluator

Simple expression evaluator for C#

Getting Started

  1. Install via nuget: ExpressionEvaluatorCs https://www.nuget.org/packages/ExpressionEvaluatorCs/
  2. Sample code
// Returns 6
object result1 = ExpressionEvaluator.Evaluate("(1 + 2) * 2");

// Returns false
object result2 = ExpressionEvaluator.Evaluate("false and true");

.NET Support

  • Current Release: .NET Framework 4
  • Future release: .NET Core (.NET Standard Library)

Expression Support

  • And
  • False
  • Not
  • Or
  • True

Operator Support

  • <
  • >
  • <=
  • >=
  • <>
  • =
  • +
  • -
  • *
  • /
  • %

Options

Specify Return Type

Sample code

// Returns 6
int result1 = ExpressionEvaluator.Evaluate<int>("(1 + 2) * 2");

// Returns false
bool result2 = ExpressionEvaluator.Evaluate<bool>("false and true");

Specify Operator Mapping

TBD