Skip to content

Commit f8a584e

Browse files
author
linzhijun
committed
fix README
1 parent 2fe0cde commit f8a584e

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

README-EN.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ ToolGood.Algorithm is a powerful, lightweight, `Excel formula` compatible algori
3737
var j = engine.TryEvaluate("json('{\"Name\":\"William Shakespeare\", \"Age\":51, \"Birthday\":\"04/26/1564 00:00:00\"}').Age", null);//Return 51 返回51
3838
var k = engine.TryEvaluate("json('{\"Name\":\"William Shakespeare \", \"Age\":51, \"Birthday\":\"04/26/1564 00:00:00\"}')[Name].Trim()", null);//Return to "William Shakespeare" 返回"William Shakespeare" (不带空格)
3939
var l = engine.TryEvaluate("json('{\"Name1\":\"William Shakespeare \", \"Age\":51, \"Birthday\":\"04/26/1564 00:00:00\"}')['Name'& 1].Trim().substring(2, 3)", null); ;//Return "ill" 返回"ill"
40+
var n = engine.TryEvaluate("{Name:\"William Shakespeare\", Age:51, Birthday:\"04/26/1564 00:00:00\"}.Age", null);//Return 51 返回51
41+
var m = engine.TryEvaluate("{1,2,3,4,5,6}.has(13)", true);//Return false 返回false
4042
4143
```
4244
Constants`pi`, `e`, `true`, `false`are supported.
@@ -53,6 +55,10 @@ The default index is`excel index`. If you want to use c# index, please set`UseEx
5355

5456
Chinese symbols are automatically converted to English symbols: `brackets`, `square brackets`, `commas`, `quotation marks`, `double quotation marks`.
5557

58+
59+
Chinese symbols are automatically converted into English symbols: `brackets`, `commas`, `quotation marks`, `double quotation marks``addition`,`subtraction`, `multiplication`, `division` , `equal sign`.
60+
61+
5662
Note: Use `&` for string concatenation.
5763

5864

@@ -99,6 +105,9 @@ Note: `find` is an Excel formula , find (the string to be searched, the string t
99105
```
100106
Parameters are defined in square brackets, such as `[parameter name]`.
101107

108+
109+
Parameter definitions, such as`[parameter name]`, `【parameter name】` , `#parameter name#` , `@parameterName`.
110+
102111
Note: You can also use `AddParameter`, `AddParameterFromJson` to add methods, and use `DiyFunction`+= to customize functions.
103112

104113
Note 2: use `AlgorithmEngineHelper.GetDiyNames` get `parameter name` and `custom function name`.
@@ -117,6 +126,26 @@ Note 2: use `AlgorithmEngineHelper.GetDiyNames` get `parameter name` and `custom
117126

118127
```
119128

129+
## Support Unit
130+
131+
Standard units can be set: `DistanceUnit` (default:`m`), `AreaUnit`(default:`m2`), `VolumeUnit`(default:`m3`), `MassUnit`(default:`kg`).
132+
133+
Note: When calculating the formula, first convert the quantity with units into standard units, and then perform numerical calculations.
134+
135+
``` csharp
136+
AlgorithmEngine engine = new AlgorithmEngine();
137+
bool a = engine.TryEvaluate("1=1m", false); // return true
138+
bool b = engine.TryEvaluate("1=1m2", false); // return true
139+
bool c = engine.TryEvaluate("1=1m3", false); // return true
140+
bool d = engine.TryEvaluate("1=1kg", false); // return true
141+
142+
// Unit Conversion 单位转化
143+
var num = AlgorithmEngineHelper.UnitConversion(1M,"","千米");
144+
145+
// Example of not throwing mistakes 不抛错例子
146+
bool error = engine.TryEvaluate("1m=1m2", false); // return true
147+
```
148+
120149

121150
## Excel Formula
122151

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ bool转数值,假为`0`,真为`1`。bool转字符串,假为`FALSE`,真
5252

5353
注:字符串拼接使用`&`
5454

55-
56-
57-
5855
注:`find`为Excel公式,find(要查找的字符串, 被查找的字符串[, 开始位置])
5956

6057
## 自定义参数
@@ -117,10 +114,10 @@ bool转数值,假为`0`,真为`1`。bool转字符串,假为`FALSE`,真
117114
```
118115
## 支持单位
119116

120-
可设置标准单位:长度(默认:`m`)、面积(默认:`m2`)、体积(默认:`m3`)、重量(默认:`kg`)。
117+
可设置标准单位:长度`DistanceUnit`(默认:`m`)、面积`AreaUnit`(默认:`m2`)、体积`VolumeUnit`(默认:`m3`)、重量`MassUnit`(默认:`kg`)。
121118

122119
注:公式计算时,先将带单位的数量转成标准单位,再进行数字计算。
123-
120+
124121
``` csharp
125122
AlgorithmEngine engine = new AlgorithmEngine();
126123
bool a = engine.TryEvaluate("1=1m", false); // return true

csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_v3.5.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public void Json_test()
6060
b = engine.TryEvaluate("{name:'toolgood', age:'12',other:{work:'IT'}}.hasKey('age')", false);
6161
Assert.AreEqual(b, true);
6262

63+
b = engine.TryEvaluate("{e:'toolgood', pi:'12',other:{work:'IT'}}.hasKey('e')", false);
64+
Assert.AreEqual(b, true);
65+
6366
b = engine.TryEvaluate("json(\"{'name':'toolgood', 'age':'12','other':{'work':'IT'}}\").has('age')", false);
6467
Assert.AreEqual(b, true);
6568

@@ -74,6 +77,8 @@ public void Json_test()
7477

7578
b = engine.TryEvaluate("json(\"{'name':'toolgood', 'age':'12','other':{'work':'IT'}}\").hasValue('toolgood')", false);
7679
Assert.AreEqual(b, true);
80+
81+
7782
}
7883

7984
[Test]

0 commit comments

Comments
 (0)