SerializableFormula 2.1.0
dotnet add package SerializableFormula --version 2.1.0
NuGet\Install-Package SerializableFormula -Version 2.1.0
<PackageReference Include="SerializableFormula" Version="2.1.0" />
paket add SerializableFormula --version 2.1.0
#r "nuget: SerializableFormula, 2.1.0"
// Install SerializableFormula as a Cake Addin #addin nuget:?package=SerializableFormula&version=2.1.0 // Install SerializableFormula as a Cake Tool #tool nuget:?package=SerializableFormula&version=2.1.0
Serializable Formula
Serializable Formula is a fast library used to calculate a text based formula input all contained in a convienent serializable object. Add your own custom functions and variables. Calculate Boolean, String and Float outputs.
Usage
Initialization
Start by creating a simple SerializableFormula object, setting the desired result type and the formula text.
var newFormula = new SerializableFormula();
newFormula.FormulaResultType = TResultType.Float;
newformula.FormulaText = "Average(a, b, c, d, e)";
Defining Custom Variables
Now you have to define each part of the function. The SerializableFormula object above has no ability to process each function until you tell it what each part does.
Define your variables:
var a = new FormulaVariable("a", 4);
var b = new FormulaVariable("b", 2);
var c = new FormulaVariable("c", 7);
var d = new FormulaVariable("d", 10);
var e = new FormulaVariable("e", 20);
newFormula.AddVariable(a);
newFormula.AddVariable(b);
newFormula.AddVariable(c);
newFormula.AddVariable(d);
newFormula.AddVariable(e);
Defining Functions
Define the Average
function:
var average = new TAverageFunction();
newFormula.AddFunction(average);
The Average
function is a custom function that comes bundled with the SerializableFormula. More about custom functions later.
Verify Syntax
Use the VerifySyntax()
function to return an object SyntaxCheckResult
which contains:
ExpressionError
: A string containing a human friendly error messageExpressionErrorToken
: A string with just the erroneous text tokenExpressionErrorPosition
: A integer representing the position in the formula string where the error occurs
Calculation
Finally, we can obtain our result by calling the function that matches our output type:
var result = newFormula.CalculateText();
var result = newFormula.CalculateLogical();
var result = newFormula.CalculateArithmetic();
Custom Functions
In order to create a custom function all you have to do is create a new object that implements IFormulaFunction
.
Once implemented you can add your function to a SerializableFormula using the AddFunction()
method.
Default Identifiers
These identifiers are always a part of SerializableFormula. They cannot be used to name Functions or Variables.
Boolean
or
xor
and
true
false
not
if
case
Math Operators
+
-
<
<=
>
>=
<>
=
/
*
^
(
)
,
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 was computed. 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. |
-
.NETStandard 2.0
- Essy.Math.Statistical (>= 2.6.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SerializableFormula:
Package | Downloads |
---|---|
WPFFormulaBox
A WPF component that hosts a Serializable Formula |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
2.1.0 | 275 | 4/19/2023 | |
2.0.0 | 167 | 4/18/2023 | |
1.10.0 | 333 | 12/16/2022 | |
1.9.0 | 339 | 11/14/2022 | |
1.8.1 | 445 | 3/1/2021 | |
1.8.0 | 459 | 3/1/2021 | |
1.7.1 | 1,032 | 7/17/2018 | |
1.7.0 | 939 | 7/16/2018 | |
1.6.1 | 1,367 | 5/14/2018 | |
1.6.0 | 1,268 | 5/14/2018 | |
1.4.0 | 1,575 | 5/2/2018 | |
1.3.0 | 1,048 | 5/2/2018 | |
1.2.0 | 1,009 | 4/30/2018 | |
1.1.0 | 1,160 | 4/30/2018 | |
1.0.0 | 1,611 | 4/28/2018 |
Fixed issues with the "not" operator.