Skip to content

Commit b337e8b

Browse files
author
linzhijun
committed
fix
1 parent e6b8ed9 commit b337e8b

File tree

10 files changed

+1043
-717
lines changed

10 files changed

+1043
-717
lines changed

csharp/ToolGood.Algorithm.WebAssembly/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static string TryEvaluateString(string exp, string def = null, string dat
3939
try {
4040
var fun = ae.Parse(exp);
4141
result["parse"] = true;
42-
var obj = fun.Calculate(ae);
42+
var obj = fun.Evaluate(ae);
4343
if (obj.IsNull) {
4444
result["result"] = null;
4545
return JsonSerializer.Serialize(result);
@@ -93,7 +93,7 @@ public static string TryEvaluateNumber(string exp, decimal def, string data = nu
9393
try {
9494
var fun = ae.Parse(exp);
9595
result["parse"] = true;
96-
var obj = fun.Calculate(ae);
96+
var obj = fun.Evaluate(ae);
9797
obj = obj.ToNumber("It can't be converted to bool!");
9898
if (obj.IsError) {
9999
result["result"] = def;
@@ -138,7 +138,7 @@ public static string TryEvaluateBool(string exp, bool def, string data = null, s
138138
try {
139139
var fun = ae.Parse(exp);
140140
result["parse"] = true;
141-
var obj = fun.Calculate(ae);
141+
var obj = fun.Evaluate(ae);
142142
obj = obj.ToBoolean("It can't be converted to bool!");
143143
if (obj.IsError) {
144144
result["result"] = def;
@@ -183,7 +183,7 @@ public static string TryEvaluateDateTime(string exp, DateTime def, string data =
183183
try {
184184
var fun = ae.Parse(exp);
185185
result["parse"] = true;
186-
var obj = fun.Calculate(ae);
186+
var obj = fun.Evaluate(ae);
187187
obj = obj.ToMyDate("It can't be converted to datetime!");
188188
if (obj.IsError) {
189189
result["result"] = def;

csharp/ToolGood.Algorithm/AlgorithmEngine.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class AlgorithmEngine
4343
/// <summary>
4444
/// 最后一个错误
4545
/// </summary>
46-
public string LastError { get; private set; }
46+
public string LastError { get; internal set; }
4747

4848
/// <summary>
4949
/// 使用EXCEL索引
@@ -108,7 +108,7 @@ public FunctionBase Parse(string exp)
108108
/// <returns></returns>
109109
public Operand Evaluate(FunctionBase function)
110110
{
111-
return function.Calculate(this);
111+
return function.Evaluate(this);
112112
}
113113

114114
#endregion Parse Evaluate
@@ -125,7 +125,7 @@ public ushort TryEvaluate(string exp, ushort def)
125125
{
126126
try {
127127
var function = Parse(exp);
128-
var obj = function.Calculate(this);
128+
var obj = function.Evaluate(this);
129129
if (obj.IsNotNumber) {
130130
obj = obj.ToNumber("It can't be converted to number!");
131131
if (obj.IsError) {
@@ -150,7 +150,7 @@ public uint TryEvaluate(string exp, uint def)
150150
{
151151
try {
152152
var function = Parse(exp);
153-
var obj = function.Calculate(this);
153+
var obj = function.Evaluate(this);
154154
if (obj.IsNotNumber) {
155155
obj = obj.ToNumber("It can't be converted to number!");
156156
if (obj.IsError) {
@@ -175,7 +175,7 @@ public ulong TryEvaluate(string exp, ulong def)
175175
{
176176
try {
177177
var function = Parse(exp);
178-
var obj = function.Calculate(this);
178+
var obj = function.Evaluate(this);
179179
if (obj.IsNotNumber) {
180180
obj = obj.ToNumber("It can't be converted to number!");
181181
if (obj.IsError) {
@@ -200,7 +200,7 @@ public short TryEvaluate(string exp, short def)
200200
{
201201
try {
202202
var function = Parse(exp);
203-
var obj = function.Calculate(this);
203+
var obj = function.Evaluate(this);
204204
if (obj.IsNotNumber) {
205205
obj = obj.ToNumber("It can't be converted to number!");
206206
if (obj.IsError) {
@@ -225,7 +225,7 @@ public int TryEvaluate(string exp, int def)
225225
{
226226
try {
227227
var function = Parse(exp);
228-
var obj = function.Calculate(this);
228+
var obj = function.Evaluate(this);
229229
if (obj.IsNotNumber) {
230230
obj = obj.ToNumber("It can't be converted to number!");
231231
if (obj.IsError) {
@@ -250,7 +250,7 @@ public long TryEvaluate(string exp, long def)
250250
{
251251
try {
252252
var function = Parse(exp);
253-
var obj = function.Calculate(this);
253+
var obj = function.Evaluate(this);
254254
if (obj.IsNotNumber) {
255255
obj = obj.ToNumber("It can't be converted to number!");
256256
if (obj.IsError) {
@@ -275,7 +275,7 @@ public float TryEvaluate(string exp, float def)
275275
{
276276
try {
277277
var function = Parse(exp);
278-
var obj = function.Calculate(this);
278+
var obj = function.Evaluate(this);
279279
if (obj.IsNotNumber) {
280280
obj = obj.ToNumber("It can't be converted to number!");
281281
if (obj.IsError) {
@@ -300,7 +300,7 @@ public double TryEvaluate(string exp, double def)
300300
{
301301
try {
302302
var function = Parse(exp);
303-
var obj = function.Calculate(this);
303+
var obj = function.Evaluate(this);
304304
if (obj.IsNotNumber) {
305305
obj = obj.ToNumber("It can't be converted to number!");
306306
if (obj.IsError) {
@@ -325,7 +325,7 @@ public decimal TryEvaluate(string exp, decimal def)
325325
{
326326
try {
327327
var function = Parse(exp);
328-
var obj = function.Calculate(this);
328+
var obj = function.Evaluate(this);
329329
if (obj.IsNotNumber) {
330330
obj = obj.ToNumber("It can't be converted to number!");
331331
if (obj.IsError) {
@@ -350,7 +350,7 @@ public string TryEvaluate(string exp, string def)
350350
{
351351
try {
352352
var function = Parse(exp);
353-
var obj = function.Calculate(this);
353+
var obj = function.Evaluate(this);
354354
if (obj.IsNotText) {
355355
obj = obj.ToText("It can't be converted to string!");
356356
if (obj.IsError) {
@@ -375,7 +375,7 @@ public bool TryEvaluate(string exp, bool def)
375375
{
376376
try {
377377
var function = Parse(exp);
378-
var obj = function.Calculate(this);
378+
var obj = function.Evaluate(this);
379379
if (obj.IsNotBoolean) {
380380
obj = obj.ToBoolean("It can't be converted to bool!");
381381
if (obj.IsError) {
@@ -400,7 +400,7 @@ public DateTime TryEvaluate(string exp, DateTime def)
400400
{
401401
try {
402402
var function = Parse(exp);
403-
var obj = function.Calculate(this);
403+
var obj = function.Evaluate(this);
404404
if (obj.IsNotDate) {
405405
obj = obj.ToMyDate("It can't be converted to DateTime!");
406406
if (obj.IsError) {
@@ -428,7 +428,7 @@ public TimeSpan TryEvaluate(string exp, TimeSpan def)
428428
{
429429
try {
430430
var function = Parse(exp);
431-
var obj = function.Calculate(this);
431+
var obj = function.Evaluate(this);
432432
if (obj.IsNotDate) {
433433
obj = obj.ToMyDate("It can't be converted to DateTime!");
434434
if (obj.IsError) {
@@ -454,7 +454,7 @@ public MyDate TryEvaluate_MyDate(string exp, MyDate def)
454454
{
455455
try {
456456
var function = Parse(exp);
457-
var obj = function.Calculate(this);
457+
var obj = function.Evaluate(this);
458458
if (obj.IsNotDate) {
459459
obj = obj.ToMyDate("It can't be converted to DateTime!");
460460
if (obj.IsError) {

0 commit comments

Comments
 (0)