FY.Evaluator
1.0.2
dotnet add package FY.Evaluator --version 1.0.2
NuGet\Install-Package FY.Evaluator -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FY.Evaluator" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FY.Evaluator" Version="1.0.2" />
<PackageReference Include="FY.Evaluator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FY.Evaluator --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FY.Evaluator, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FY.Evaluator@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FY.Evaluator&version=1.0.2
#tool nuget:?package=FY.Evaluator&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
1. 运算符定义
1.1 关系运算符
元素表示一个数字或一个字符串
- 数字可以是整数或者小数,如1、2.3、-5、-6.8等
- 数字判断只判断数值,如5=5.0是真、5=5是真、5=5.2是假
- 字符串只能由数字和字母组成,如A01、Ba、32、5A等
集合表示多个元素
- 集合的各元素以英文逗号分隔,如A,B,C、1,2,3、A,5,6等
- 左集合的元素和右集合的元素全部为数字时,将判断数值,如1,2.0,3=1.0,2,3是真,1.0∈1,2,3是真,1.0,2⊂1,2.0,3是真
- 集合的判断与集合内元素的顺序无关,如A,B,C=B,C,A是真,2,1.0⊂1,2,3是真
| 符号 | 名称 | 说明 | 元素与元素示例 | 元素与集合示例 | 集合与集合示例 |
|---|---|---|---|---|---|
| = | 相等 | 元素与元素、集合与集合 | A=B | A,B,C=A,M,N | |
| == | 相等 | 元素与元素、集合与集合 | A==B | A,B,C==A,M,N | |
| ≠ | 不相等 | 元素与元素、集合与集合 | A≠B | A,B,C=A,M,N | |
| != | 不相等 | 元素与元素、集合与集合 | A!=B | A,B,C=A,M,N | |
| <> | 不相等 | 元素与元素、集合与集合 | A<>B | A,B,C=A,M,N | |
| < | 小于 | 数字与数字 | A<B | ||
| ≤ | 小于或等于 | 数字与数字 | A≤B | ||
| ⇐ | 小于或等于 | 数字与数字 | A<=B | ||
| > | 大于 | 数字与数字 | A>B | ||
| ≥ | 大于或等于 | 数字与数字 | A≥B | ||
| >= | 大于或等于 | 数字与数字 | A>=B | ||
| ∈ | 属于 | 元素与集合 | A ∈ A,B,C | ||
| ∉ | 不属于 | 元素与集合 | A ∉ A,B,C | ||
| ∋ | 包含 | 元素与集合 | A ∋ A,B,C | ||
| ∌ | 不包含 | 元素与集合 | A ∌ A,B,C | ||
| ⊆ | 子集 | 集合与集合 | A,B,C ⊂ A,B,C | ||
| ⊂ | 真子集 | 集合与集合 | A,B ⊂ A,B,C | ||
| ⊇ | 超集 | 集合与集合 | A,B,C ⊇ A,B,C | ||
| ⊃ | 真超集 | 集合与集合 | A,B,C ⊃ A,B | ||
| ∩ | 有交集 | 集合与集合 | A,B,C ∩ B,C,D | ||
| ∅ | 无交集 | 集合与集合 | A,B,C ∅ X,Y,Z |
1.2 逻辑运算符
可用英文小括号来指定优先级,如 ((A=B || C=D) && M=N) && (X=Y || E=F)
| 符号 | 名称 | 说明 | 示例 |
|---|---|---|---|
| && | 且 | 表示左表达式和右表达式同时满足时为真 | A=B && C=D |
| || | 或 | 表示左表达式和右表达式至少有一个满足时为真 | A=B || C=D |
2. 示例代码
2.1 判断表达式
var expression = "1,2=2,1 && (A∈A,B,C || M,N ⊂ X,Y,Z)";
var res = ExpressionEvaluator.Evaluate(expression);
Console.WriteLine(res);
// 输出:true
2.2 判断表达式(带参数)
var parameter = new Dictionary<string, string>();
parameter.Add("Opt01", "1,2");
parameter.Add("Opt02", "A");
var expression = "Opt01=2,1 && (Opt02∈A,B,C || M,N ⊂ X,Y,Z)";
var res = ExpressionEvaluator.Evaluate(expression, parameter);
Console.WriteLine(res);
// 输出:true
2.3 解析表达式树
var expression = "Opt01=2,1 && (Opt02∈A,B,C || M,N ⊂ X,Y,Z)";
var expressionNode = ExpressionParser.ParseExpression();
2.4 解析原子表达式
var expression = "Opt01=2,1";
var atomicExpression = ExpressionParser.ParseAtomicExpression(expression);
Console.WriteLine($"左值:{atomicExpression.Left}");
Console.WriteLine($"符号:{atomicExpression.Operator}");
Console.WriteLine($"右值:{atomicExpression.Right}");
// 输出:左值:Opt01
// 输出:符号:=
// 输出:右值:2,1
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FY.Evaluator:
| Package | Downloads |
|---|---|
|
FY.Condition
用于条件判断等相关 |
GitHub repositories
This package is not used by any popular GitHub repositories.