Skip to content

Commit cb2a66d

Browse files
committed
修改readme
1 parent ad98ed7 commit cb2a66d

File tree

1 file changed

+75
-40
lines changed

1 file changed

+75
-40
lines changed

README.md

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,87 @@
11
ToolGood.Algorithm
22
===================
3+
4+
ToolGood.Algorithm supports `Four arithmetic`, `Excel function`, and supports `Custom parameters`.
5+
36
ToolGood.Algorithm支持`四则运算``Excel函数`,并支持`自定义参数`
47

5-
注:不兼容1.x版本
8+
9+
**Applicable scenarios:** Code and algorithm are separated to avoid forced project upgrade
610

711
**适用场景:** 代码与算法分离,避免项目强制升级
812

13+
1)Uncertain algorithm at the beginning of the project;
14+
915
1)项目初期,未确定的算法;
1016

17+
2)Algorithms that are frequently changed during project maintenance;
18+
1119
2)项目维护时,经常改动的算法;
1220

13-
3)财务数据、统计数据之中的算法,(注:本项目使用double类型,建议使用``为单位);
21+
3)Algorithms in financial data and statistical data (Note: This project uses `double` type, and it is recommended to use `fen` as the unit);
22+
23+
3)财务数据、统计数据之中的算法,(注:本项目使用`double`类型,建议使用``为单位);
24+
25+
4)The report is exported, the data source uses the stored procedure, and the algorithm is set in the Word document. Example https://github.com/toolgood/ToolGood.WordTemplate
1426

1527
4)报表导出,数据来源使用存储过程,Word文档内设置算法。例 https://github.com/toolgood/ToolGood.WordTemplate
1628

17-
## 快速上手
29+
## Quick start(快速上手)
1830
``` csharp
1931
AlgorithmEngine engine = new AlgorithmEngine();
2032
double a=0.0;
2133
if (engine.Parse("1+2")) {
2234
var o = engine.Evaluate();
2335
a=o.NumberValue;
2436
}
25-
var b = engine.TryEvaluate("1=1 && 1<2 and 7-8>1", 0);// 支持 && || and or
37+
var b = engine.TryEvaluate("1=1 && 1<2 and 7-8>1", 0);// Support(支持) && || and or
2638
var c = engine.TryEvaluate("2+3", 0);
27-
var d = engine.TryEvaluate("count({1,2,3,4})", 0);//{}代表数组,返回:4
28-
var s = engine.TryEvaluate("'aa'&'bb'", ""); //字符串连接,返回:aabb
29-
var r = engine.TryEvaluate("(1=1)*9+2", 0); //返回:11
30-
var d = engine.TryEvaluate("'2016-1-1'+1", DateTime.MinValue); //返回日期:2016-1-2
31-
var t = engine.TryEvaluate("'2016-1-1'+9*'1:0'", DateTime.MinValue);//返回日期:2016-1-1 9:0
32-
var j = engine.TryEvaluate("json('{\"Name\":\"William Shakespeare\",\"Age\":51,\"Birthday\":\"04/26/1564 00:00:00\"}').Age", null);//返回51
33-
var k = engine.TryEvaluate("json('{\"Name\":\"William Shakespeare \",\"Age\":51,\"Birthday\":\"04/26/1564 00:00:00\"}')[Name].Trim()", null);//返回"William Shakespeare" (不带空格)
34-
var l = engine.TryEvaluate("json('{\"Name1\":\"William Shakespeare \",\"Age\":51,\"Birthday\":\"04/26/1564 00:00:00\"}')['Name'& 1].Trim().substring(2,3)", null); ;//返回"ill"
39+
var d = engine.TryEvaluate("count({1,2,3,4})", 0);//{} represents array, return: 4 {}代表数组,返回:4
40+
var s = engine.TryEvaluate("'aa'&'bb'", ""); //String connection, return: AABB 字符串连接,返回:aabb
41+
var r = engine.TryEvaluate("(1=1)*9+2", 0); //Return: 11 返回:11
42+
var d = engine.TryEvaluate("'2016-1-1'+1", DateTime.MinValue); //Return date: 2016-1-2 返回日期:2016-1-2
43+
var t = engine.TryEvaluate("'2016-1-1'+9*'1:0'", DateTime.MinValue);//Return datetime:2016-1-1 9:0 返回日期:2016-1-1 9:0
44+
var j = engine.TryEvaluate("json('{\"Name\":\"William Shakespeare\",\"Age\":51,\"Birthday\":\"04/26/1564 00:00:00\"}').Age", null);//Return 51 返回51
45+
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" (不带空格)
46+
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"
3547
3648
```
49+
50+
Constants`pi`,`e`,`true`,`false`are supported.
51+
3752
支持常量`pi`,`e`,`true`,`false`
3853

39-
数值转bool,非零为真,零为假。
40-
字符串转bool,`0``FALSE`为假,`1``TRUE`为真。不区分大小写
54+
The value is converted to bool, non-zero is true and zero is false.
55+
String to bool, ` 0 ', ` false' is false, ` 1 ', ` true' is true. Case insensitive.
56+
57+
数值转bool,非零为真,零为假。字符串转bool,`0``FALSE`为假,`1``TRUE`为真。不区分大小写。
58+
4159

42-
bool转数值,假为`0`,真为`1`
43-
bool转字符串,假为`FALSE`,真为`TRUE`
60+
Bool to value, false is`0`, true is`1`.
61+
Bool to string, false to`FALSE`, true to`TRUE`.
62+
63+
bool转数值,假为`0`,真为`1`。bool转字符串,假为`FALSE`,真为`TRUE`
64+
65+
The default index is`excel index`. If you want to use c# index, please set`useexcelindex`to`false`.
4466

4567
索引默认为`Excel索引`,如果想用c#索引,请设置`UseExcelIndex``false`
4668

47-
中文符号自动转成英文符号:`括号`,`方括号`,`逗号`,`引号`,`双引号`
69+
70+
Chinese symbols are automatically converted to English symbols: `brackets`, `square brackets`,`commas`, `quotation marks`,`double quotation marks`.
71+
72+
中文符号自动转成英文符号:`括号`,`方括号`,`逗号`,`引号`,`双引号`
73+
74+
Note: Use `&` for string concatenation.
4875

4976
注:字符串拼接使用`&`
5077

78+
Note: `find` is an Excel function, find (the string to be searched, the string to be searched [,start position])
79+
5180
注:`find`为Excel函数,find(要查找的字符串,被查找的字符串[,开始位置])
5281

53-
## 自定义参数
82+
## Custom parameters(自定义参数)
5483
``` csharp
55-
//定义圆柱信息
84+
//Define cylinder information 定义圆柱信息
5685
public class Cylinder : AlgorithmEngine
5786
{
5887
private int _radius;
@@ -80,26 +109,39 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
80109
return base.GetParameter(parameter);
81110
}
82111
}
83-
//调用方法
112+
//Call method 调用方法
84113
Cylinder c = new Cylinder(3, 10);
85-
c.TryEvaluate("[半径]*[半径]*pi()", 0.0); //圆底面积
86-
c.TryEvaluate("[直径]*pi()", 0.0); //圆的长
87-
c.TryEvaluate("[半径]*[半径]*pi()*[高]", 0.0); //圆的体积
88-
c.TryEvaluate("['半径']*[半径]*pi()*[高]", 0.0); //圆的体积
114+
c.TryEvaluate("[半径]*[半径]*pi()", 0.0); //Round bottom area 圆底面积
115+
c.TryEvaluate("[直径]*pi()", 0.0); //The length of the circle 圆的长
116+
c.TryEvaluate("[半径]*[半径]*pi()*[高]", 0.0); //Volume of circle 圆的体积
117+
c.TryEvaluate("['半径']*[半径]*pi()*[高]", 0.0); //Volume of circle 圆的体积
89118
```
119+
Parameters are defined in square brackets, such as `[parameter name]`.
120+
90121
参数以方括号定义,如 `[参数名]`
91122

123+
Note: You can also use `AddParameter`, `AddParameterFromJson` to add methods, and use `DiyFunction`+= to customize functions.
124+
92125
注:还可以使用`AddParameter``AddParameterFromJson`添加方法,使用`DiyFunction`+=来自定义函数。
93126

94-
## Excel函数
127+
## Excel functions(Excel函数)
128+
129+
Functions: `logical functions`, `mathematics and trigonometric functions`, `text functions`, `statistical functions`, `date and time functions`
130+
95131
函数:`逻辑函数``数学与三角函数``文本函数``统计函数``日期与时间函数`
96132

133+
Note: Function names are not case sensitive. Parameters with square brackets can be omitted. The return value of the example is approximate.
134+
97135
注:函数名不分大小写,带方括号的参数可省略,示例的返回值,为近似值。
98136

137+
Note 2: The function name with ★ indicates that the first parameter can be prefixed, such as `(-1).ISTEXT()`
138+
99139
注2:函数名带★,表示第一个参数可以前置,如`(-1).ISTEXT()`
100140

141+
Note 3: The function name with ▲ means that it is affected by `Excel Index`,
142+
101143
注3:函数名带▲,表示受`Excel索引`影响,
102-
#### 逻辑函数
144+
#### Logical function (逻辑函数)
103145
<table>
104146
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
105147
<tr>
@@ -180,7 +222,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
180222
</tr>
181223
</table>
182224

183-
#### 数学与三角函数
225+
#### Mathematics and Trigonometric Functions(数学与三角函数)
184226
<table>
185227
<tr><td>分类</td><td>函数名</td><td>说明</td><td>示例</td></tr>
186228
<tr>
@@ -439,7 +481,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
439481
</tr>
440482
</table>
441483

442-
#### 文本函数
484+
#### Text function(文本函数)
443485
<table>
444486
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
445487
<tr>
@@ -545,7 +587,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
545587
</tr>
546588
</table>
547589

548-
#### 日期与时间函数
590+
#### Date and time functions (日期与时间函数)
549591
<table>
550592
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
551593
<tr>
@@ -630,7 +672,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
630672
</tr>
631673
</table>
632674

633-
#### 统计函数
675+
#### Statistical function (统计函数)
634676
<table>
635677
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
636678
<tr>
@@ -819,7 +861,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
819861
</tr>
820862
</table>
821863

822-
#### 查找引用
864+
#### Find references (查找引用)
823865
<table>
824866
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
825867
<tr>
@@ -830,7 +872,7 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
830872
</tr>
831873
</table>
832874

833-
#### 增加函数 类C#方法
875+
#### Add function similar to C# method (增加函数 类C#方法)
834876
<table>
835877
<tr><td>函数名</td><td>说明</td><td>示例</td></tr>
836878
<tr>
@@ -941,11 +983,4 @@ bool转字符串,假为`FALSE`,真为`TRUE`。
941983
</table>
942984

943985

944-
## 捐赠
945-
946-
如果这个类库有帮助到您,请 Star 这个仓库。
947-
948-
你也可以选择使用支付宝或微信给我捐赠:
949-
950-
![Alipay, WeChat](https://toolgood.github.io/image/toolgood.png)
951-
986+

0 commit comments

Comments
 (0)