Mastersign.Expressions
0.5.2
See the version list below for details.
dotnet add package Mastersign.Expressions --version 0.5.2
NuGet\Install-Package Mastersign.Expressions -Version 0.5.2
<PackageReference Include="Mastersign.Expressions" Version="0.5.2" />
paket add Mastersign.Expressions --version 0.5.2
#r "nuget: Mastersign.Expressions, 0.5.2"
// Install Mastersign.Expressions as a Cake Addin #addin nuget:?package=Mastersign.Expressions&version=0.5.2 // Install Mastersign.Expressions as a Cake Tool #tool nuget:?package=Mastersign.Expressions&version=0.5.2
Project Description
Mastersign.Expression is a small DSL (domain specific language) a little like the MS EXCEL formular language. The purpose is to provide a simple expression language with a set of predefined functions for math and string manipulation. Expressions are parsed via a parser, based on the Sprache parser framework, and compiled via System.Linq.Expressions into a lambda delegate and can therefore used repeatedly with acceptable performance.
Features
It supports numeric, boolean and string literals, operators for numeric operations, string concatenation, logical combination and comparison. Grouping is done with parantheses. Function calls have a C-style-syntax. Functions, variables, constants, and parameters are provided via an evaluation context, which can be easily extended by the developer.
Mastersign.Expressions comes with a set of predefined functions for math, string manipulation and regular expressions. For detailed description, see packages.
The evaluation context can be configured to ignore the case of operator keywords, literal keywords, variables, parameters, and function names.
Expression Examples
1 + 2
pi * (100f + 32.0/a)
"\tName: " & name
"result = " & (sin(pi * 2.0 + x) / 10)
For a detailed description of expression language syntax see expression syntax.
Simple Usage Scenario
using System;
using de.mastersign.expressions;
static class Program
{
static void Main()
{
// create the evaluation context for the expression
var context = new EvaluationContext();
// load the default packages with functions and constants (math, string, ...)
context.LoadAllPackages();
// add a custom variable
context.SetVariable("x", 4);
// add a custom function
context.AddFunction("neg", (Func<double, double>)(v => -v));
// set parameter list
context.SetParameters(new ParameterInfo("a", typeof(int)));
// compile the expression into a lamda delegate
var function = context.CompileExpression<int, double>("sin(pi * neg(10 + x)) + a");
// call the delegate and write the result to the console
Console.WriteLine(function(50));
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.