Dubacik22.Equationer
1.0.1
See the version list below for details.
dotnet add package Dubacik22.Equationer --version 1.0.1
NuGet\Install-Package Dubacik22.Equationer -Version 1.0.1
<PackageReference Include="Dubacik22.Equationer" Version="1.0.1" />
paket add Dubacik22.Equationer --version 1.0.1
#r "nuget: Dubacik22.Equationer, 1.0.1"
// Install Dubacik22.Equationer as a Cake Addin #addin nuget:?package=Dubacik22.Equationer&version=1.0.1 // Install Dubacik22.Equationer as a Cake Tool #tool nuget:?package=Dubacik22.Equationer&version=1.0.1
formula parsing library.
this library can parse string equations and recognize user functions and user variables like: "func1(null, 1, var0, func2(var1, some.other.var2)+'str', -60)" where va0, var1, some.other.var2 are recognized as variables func1, func2 are recognized as functions and 'str' is recognized as string constant. allso -60 as bool constant
returns ICalculatable which has GetCalculatedValue() to get the result
if there is a variable in the formula, then the parser gets it using the "FetchVariable" fetcher. this fetcher must return the IGetVariable class, which must have the property Variable of type object, but it is useful if it returns a double, bool or string. if there is a function in the formula, then the parser gets it using the "FetchFunction" fetcher. this fetcher must return an IFunction class which must have a double Calculate(IEnumerable<double> arguments)
when string "(4>5)==false" is parsed, and GetCalculatedValue() of resulting ICalculatable is called, we gets true as result. the GetCalculatedValue() of Calculatable calls Variable getter for each IGetVariable and Calculate method for each IFunction class and returns resulting object.
example:
public class DummyValue : IGetVariable
{
public object Variable { get => double.NaN; }
}
public class DummyFunc : IFunction
{
public object Calculate(IEnumerable<object> arguments)
{
return arguments.First();
}
}
public class Test()
{
var parser = new EquationParser
{
FetchFunction = name => new DummyFunc(),
FetchVariable = name => new DummyValue(),
}
parser.Parse("(v) ? 1 : (v > 1) ? 's' : f(v, 2)");
parser.Parse("(4>5)==false");
parser.Parse("(true) and ('qw' == 'ivan')");
parser.Parse("(true) ? (4 gteq 4) ? 1 : 2 : 3");
parser.Parse("func1(null, 1, #var0, func2(var1, some.other.var2)+'_a', -60)");
}
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.20 | 71 | 5/13/2024 |
1.0.19 | 220 | 11/21/2023 |
1.0.18 | 106 | 11/21/2023 |
1.0.16 | 179 | 7/28/2023 |
1.0.15 | 144 | 7/18/2023 |
1.0.14 | 176 | 7/4/2023 |
1.0.13 | 192 | 6/28/2023 |
1.0.12 | 157 | 6/27/2023 |
1.0.11 | 158 | 6/27/2023 |
1.0.10 | 161 | 6/20/2023 |
1.0.9 | 161 | 6/19/2023 |
1.0.8 | 157 | 6/13/2023 |
1.0.7 | 149 | 6/5/2023 |
1.0.6 | 170 | 5/31/2023 |
1.0.5 | 438 | 9/17/2022 |
1.0.4 | 399 | 8/16/2022 |
1.0.3 | 453 | 3/4/2022 |
1.0.2 | 443 | 2/4/2022 |
1.0.1 | 5,233 | 11/24/2021 |
1.0.1