Skip to content

Commit 8227226

Browse files
committed
fix
1 parent b0e06d8 commit 8227226

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

csharp/ToolGood.Algorithm/Internals/Functions/FunctionBase.csharp.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public override Operand Calculate(AlgorithmEngine work)
106106
var t = encoding.GetString(Base64.FromBase64String(args[0].TextValue));
107107
return Operand.Create(t);
108108
} catch (Exception) { }
109-
return Operand.Error("Function Base64ToText is error!");
109+
return Operand.Error("Function 'Base64ToText' is error!");
110110
}
111111
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
112112
{
@@ -134,7 +134,7 @@ public override Operand Calculate(AlgorithmEngine work)
134134
var t = encoding.GetString(Base64.FromBase64ForUrlString(args[0].TextValue));
135135
return Operand.Create(t);
136136
} catch (Exception) { }
137-
return Operand.Error("Function Base64urlToText is error!");
137+
return Operand.Error("Function 'Base64urlToText' is error!");
138138
}
139139
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
140140
{
@@ -164,7 +164,7 @@ public override Operand Calculate(AlgorithmEngine work)
164164
return Operand.Create(t);
165165
} catch (Exception) {
166166
}
167-
return Operand.Error("Function TextToBase64 is error!");
167+
return Operand.Error("Function 'TextToBase64' is error!");
168168
}
169169
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
170170
{
@@ -193,7 +193,7 @@ public override Operand Calculate(AlgorithmEngine work)
193193
var t = Base64.ToBase64ForUrlString(bytes);
194194
return Operand.Create(t);
195195
} catch (Exception) { }
196-
return Operand.Error("Function TextToBase64url is error!");
196+
return Operand.Error("Function 'TextToBase64url' is error!");
197197
}
198198
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
199199
{
@@ -216,7 +216,7 @@ public override Operand Calculate(AlgorithmEngine work)
216216

217217
var b = Regex.Match(args1.TextValue, args2.TextValue);
218218
if (b.Success == false) {
219-
return Operand.Error("Function Regex is error!");
219+
return Operand.Error("Function 'Regex' is error!");
220220
}
221221
return Operand.Create(b.Value);
222222
}
@@ -301,7 +301,7 @@ public override Operand Calculate(AlgorithmEngine work)
301301
var t = Hash.GetMd5String(encoding.GetBytes(args[0].TextValue));
302302
return Operand.Create(t);
303303
} catch (Exception ex) {
304-
return Operand.Error("Function MD5 is error!" + ex.Message);
304+
return Operand.Error("Function 'MD5' is error!" + ex.Message);
305305
}
306306
}
307307
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -330,7 +330,7 @@ public override Operand Calculate(AlgorithmEngine work)
330330
var t = Hash.GetSha1String(encoding.GetBytes(args[0].TextValue));
331331
return Operand.Create(t);
332332
} catch (Exception ex) {
333-
return Operand.Error("Function SHA1 is error!" + ex.Message);
333+
return Operand.Error("Function 'SHA1' is error!" + ex.Message);
334334
}
335335
}
336336
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -359,7 +359,7 @@ public override Operand Calculate(AlgorithmEngine work)
359359
var t = Hash.GetSha256String(encoding.GetBytes(args[0].TextValue));
360360
return Operand.Create(t);
361361
} catch (Exception ex) {
362-
return Operand.Error("Function SHA256 is error!" + ex.Message);
362+
return Operand.Error("Function 'SHA256' is error!" + ex.Message);
363363
}
364364
}
365365
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -388,7 +388,7 @@ public override Operand Calculate(AlgorithmEngine work)
388388
var t = Hash.GetSha512String(encoding.GetBytes(args[0].TextValue));
389389
return Operand.Create(t);
390390
} catch (Exception ex) {
391-
return Operand.Error("Function SHA512 is error!" + ex.Message);
391+
return Operand.Error("Function 'SHA512' is error!" + ex.Message);
392392
}
393393
}
394394
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -417,7 +417,7 @@ public override Operand Calculate(AlgorithmEngine work)
417417
var t = Hash.GetCrc32String(encoding.GetBytes(args[0].TextValue));
418418
return Operand.Create(t);
419419
} catch (Exception ex) {
420-
return Operand.Error("Function CRC32 is error!" + ex.Message);
420+
return Operand.Error("Function 'CRC32' is error!" + ex.Message);
421421
}
422422
}
423423
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -446,7 +446,7 @@ public override Operand Calculate(AlgorithmEngine work)
446446
var t = Hash.GetHmacMd5String(encoding.GetBytes(args[0].TextValue), args[1].TextValue);
447447
return Operand.Create(t);
448448
} catch (Exception ex) {
449-
return Operand.Error("Function HmacMD5 is error!" + ex.Message);
449+
return Operand.Error("Function 'HmacMD5' is error!" + ex.Message);
450450
}
451451
}
452452
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -475,7 +475,7 @@ public override Operand Calculate(AlgorithmEngine work)
475475
var t = Hash.GetHmacSha1String(encoding.GetBytes(args[0].TextValue), args[1].TextValue);
476476
return Operand.Create(t);
477477
} catch (Exception ex) {
478-
return Operand.Error("Function HmacSHA1 is error!" + ex.Message);
478+
return Operand.Error("Function 'HmacSHA1' is error!" + ex.Message);
479479
}
480480
}
481481
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -504,7 +504,7 @@ public override Operand Calculate(AlgorithmEngine work)
504504
var t = Hash.GetHmacSha256String(encoding.GetBytes(args[0].TextValue), args[1].TextValue);
505505
return Operand.Create(t);
506506
} catch (Exception ex) {
507-
return Operand.Error("Function HmacSHA256 is error!" + ex.Message);
507+
return Operand.Error("Function 'HmacSHA256' is error!" + ex.Message);
508508
}
509509
}
510510
public override void ToString(StringBuilder stringBuilder, bool addBrackets)
@@ -533,7 +533,7 @@ public override Operand Calculate(AlgorithmEngine work)
533533
var t = Hash.GetHmacSha512String(encoding.GetBytes(args[0].TextValue), args[1].TextValue);
534534
return Operand.Create(t);
535535
} catch (Exception ex) {
536-
return Operand.Error("Function HmacSHA512 is error!" + ex.Message);
536+
return Operand.Error("Function 'HmacSHA512' is error!" + ex.Message);
537537
}
538538
}
539539
public override void ToString(StringBuilder stringBuilder, bool addBrackets)

csharp/ToolGood.Algorithm/Internals/Functions/FunctionBase.math.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public override Operand Calculate(AlgorithmEngine work)
4141
var args2 = func2.Calculate(work); if (args2.Type != OperandType.NUMBER) { args2 = args2.ToNumber("Function '{0}' parameter {1} is error!", "Quotient", 2); if (args2.IsError) { return args2; } }
4242

4343
if (args2.NumberValue == 0) {
44-
return Operand.Error("Function 'Quotient' div 0 error!");
44+
return Operand.Error("Function '{0}' div 0 error!", "Quotient");
4545
}
4646
return Operand.Create((int)(args1.NumberValue / args2.NumberValue));
4747
}
@@ -405,7 +405,7 @@ public override Operand Calculate(AlgorithmEngine work)
405405
var args1 = func1.Calculate(work); if (args1.Type != OperandType.NUMBER) { args1 = args1.ToNumber("Function '{0}' parameter is error!","Cot"); if (args1.IsError) { return args1; } }
406406
var d = Math.Tan((double)args1.NumberValue);
407407
if (d == 0) {
408-
return Operand.Error("Function 'Cot' div 0 error!");
408+
return Operand.Error("Function '{0}' div 0 error!", "Cot");
409409
}
410410
return Operand.Create(1.0 / d);
411411
}
@@ -426,7 +426,7 @@ public override Operand Calculate(AlgorithmEngine work)
426426
var args1 = func1.Calculate(work); if (args1.Type != OperandType.NUMBER) { args1 = args1.ToNumber("Function '{0}' parameter is error!","Sec"); if (args1.IsError) { return args1; } }
427427
var d = Math.Cos((double)args1.NumberValue);
428428
if (d == 0) {
429-
return Operand.Error("Function 'Sec' div 0 error!");
429+
return Operand.Error("Function '{0}' div 0 error!", "Sec");
430430
}
431431
return Operand.Create(1.0 / d);
432432
}
@@ -447,7 +447,7 @@ public override Operand Calculate(AlgorithmEngine work)
447447
var args1 = func1.Calculate(work); if (args1.Type != OperandType.NUMBER) { args1 = args1.ToNumber("Function '{0}' parameter is error!","Csc"); if (args1.IsError) { return args1; } }
448448
var d = Math.Sin((double)args1.NumberValue);
449449
if (d == 0) {
450-
return Operand.Error("Function 'Csc' div 0 error!");
450+
return Operand.Error("Function '{0}' div 0 error!", "Csc");
451451
}
452452
return Operand.Create(1.0 / d);
453453
}
@@ -1203,8 +1203,8 @@ public override Operand Calculate(AlgorithmEngine work)
12031203
var o2 = FunctionUtil.F_base_GetList(args2, list2);
12041204
if (o1 == false) { return Operand.Error("Function '{0}' parameter {1} is error!", "CovarIanceS", 1); }
12051205
if (o2 == false) { return Operand.Error("Function '{0}' parameter {1} is error!", "CovarIanceS", 2); }
1206-
if (list1.Count != list2.Count) { return Operand.Error("Function 'CovarIanceS' parameter's count error!"); }
1207-
if (list1.Count == 1) { return Operand.Error("Function 'CovarIanceS' parameter's count error!"); }
1206+
if (list1.Count != list2.Count) { return Operand.Error("Function '{0}' parameter's count error!", "CovarIanceS"); }
1207+
if (list1.Count == 1) { return Operand.Error("Function '{0}' parameter's count error!", "CovarIanceS"); }
12081208

12091209
var avg1 = list1.Average();
12101210
var avg2 = list2.Average();
@@ -1237,8 +1237,8 @@ public override Operand Calculate(AlgorithmEngine work)
12371237
var o2 = FunctionUtil.F_base_GetList(args2, list2);
12381238
if (o1 == false) { return Operand.Error("Function '{0}' parameter {1} is error!", "Covar", 1); }
12391239
if (o2 == false) { return Operand.Error("Function '{0}' parameter {1} is error!", "Covar", 2); }
1240-
if (list1.Count != list2.Count) { return Operand.Error("Function 'Covar' parameter's count error!"); }
1241-
if (list1.Count == 0) { return Operand.Error("Function 'Covar' parameter's count error!"); }
1240+
if (list1.Count != list2.Count) { return Operand.Error("Function '{0}' parameter's count error!", "Covar"); }
1241+
if (list1.Count == 0) { return Operand.Error("Function '{0}' parameter's count error!", "Covar"); }
12421242

12431243
var avg1 = list1.Average();
12441244
var avg2 = list2.Average();

csharp/ToolGood.Algorithm/Internals/Functions/FunctionBase.sum.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public override Operand Calculate(AlgorithmEngine work)
217217
}
218218
}
219219
if (count == 0) {
220-
return Operand.Error("Function 'AverageIf' divide by zero error!");
220+
return Operand.Error("Function '{0}' div 0 error!", "AverageIf");
221221
}
222222
return Operand.Create(sum / count);
223223
}
@@ -651,7 +651,7 @@ public override Operand Calculate(AlgorithmEngine work)
651651
var args = new List<Operand>(); int index = 1;
652652
foreach (var item in funcs) { var aa = item.Calculate(work).ToNumber("Function '{0}' parameter {1} is error!", "Var", index++); if (aa.IsError) { return aa; } args.Add(aa); }
653653
if (args.Count == 1) {
654-
return Operand.Error("Function 'Var' parameter only one error!");
654+
return Operand.Error("Function '{0}}' parameter only one error!", "Var");
655655
}
656656

657657
List<decimal> list = new List<decimal>();
@@ -683,7 +683,7 @@ public override Operand Calculate(AlgorithmEngine work)
683683
var args = new List<Operand>(); int index = 1;
684684
foreach (var item in funcs) { var aa = item.Calculate(work).ToNumber("Function '{0}' parameter {1} is error!", "VarP", index++); if (aa.IsError) { return aa; } args.Add(aa); }
685685
if (args.Count == 1) {
686-
return Operand.Error("Function 'VAVarPRP' parameter only one error!");
686+
return Operand.Error("Function '{0}}' parameter only one error!", "VarP");
687687
}
688688
List<decimal> list = new List<decimal>();
689689
var o = FunctionUtil.F_base_GetList(args, list);

csharp/ToolGood.Algorithm/Internals/Functions/FunctionBase.value.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public override Operand Calculate(AlgorithmEngine work)
169169
var index = op.IntValue - work.ExcelIndex;
170170
if (index < obj.ArrayValue.Count)
171171
return obj.ArrayValue[index];
172-
return Operand.Error($"ARRARY index {index} greater than maximum length!");
172+
return Operand.Error("ARRARY index {0} greater than maximum length!", index.ToString());
173173
}
174174
if (obj.Type == OperandType.ARRARYJSON) {
175175
if (op.Type == OperandType.NUMBER) {

0 commit comments

Comments
 (0)