1414
1515
1616 <pre >
17- AreaUnitType = new class {
18- constructor () {
19- this .MM2 = 11 ;
20- this .CM2 = 12 ;
21- this .DM2 = 13 ;
22- this .M2 = 14 ;
23- this .KM2 = 15 ;
24- }
25- } ();
26- DistanceUnitType = new class {
27- constructor () {
28- this .MM = 1 ;
29- this .CM = 2 ;
30- this .DM = 3 ;
31- this .M = 4 ;
32- this .KM = 5 ;
33- }
34- } ();
35- MassUnitType = new class {
36- constructor () {
37- this .G = 31 ;
38- this .KG = 32 ;
39- this .T = 33 ;
40- }
41- } ();
42- VolumeUnitType = new class {
43- constructor () {
44- this .MM3 = 21 ;
45- this .CM3 = 22 ;
46- this .DM3 = 23 ;
47- this .M3 = 24 ;
48- this .KM3 = 25 ;
49- }
50- } ();
17+ DistanceUnitType = new class { constructor () { this .MM = 1 ; this .CM = 2 ; this .DM = 3 ; this .M = 4 ; this .KM = 5 ; } } ();
18+ AreaUnitType = new class { constructor () { this .MM2 = 11 ; this .CM2 = 12 ; this .DM2 = 13 ; this .M2 = 14 ; this .KM2 = 15 ; } } ();
19+ VolumeUnitType = new class { constructor () { this .MM3 = 21 ; this .CM3 = 22 ; this .DM3 = 23 ; this .M3 = 24 ; this .KM3 = 25 ; } } ();
20+ MassUnitType = new class { constructor () { this .G = 31 ; this .KG = 32 ; this .T = 33 ; } } ();
5121 AlgorithmEngine = new class {
5222 constructor () {
5323 this .UseExcelIndex = true ;
@@ -59,85 +29,31 @@ AreaUnitType = new class {
5929 this .MassUnit = MassUnitType .KG ;
6030 this .IgnoreCase = false ;
6131 }
62-
63- createOption = function () {
64- var data = {
65- UseExcelIndex : this .UseExcelIndex ,
66- UseTempDict : this .UseTempDict ,
67- UseLocalTime : this .UseLocalTime ,
68- DistanceUnit : this .DistanceUnit ,
69- AreaUnit : this .AreaUnit ,
70- VolumeUnit : this .VolumeUnit ,
71- MassUnit : this .MassUnit ,
72- IgnoreCase : this .IgnoreCase ,
73- }
74- return JSON .stringify (data );
75- }
76-
77- TryEvaluateString = async function (exp , def , data ) {
78- return await DotNet .invokeMethodAsync ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateString' , exp , def , data , this .createOption ());
79- }
80- TryEvaluateNumber = async function (exp , def , data ) {
81- return await DotNet .invokeMethodAsync ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateNumber' , exp , def , data , this .createOption ());
82- }
83- TryEvaluateBool = async function (exp , def , data ) {
84- return await DotNet .invokeMethodAsync ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateBool' , exp , def , data , this .createOption ());
85- }
86- TryEvaluateDateTime = async function (exp , def , data ) {
87- return await DotNet .invokeMethodAsync ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateDateTime' , exp , def , data , this .createOption ());
88- }
32+ TryEvaluateString = function (exp , def , data ) { return DotNet .invokeMethod ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateString' , exp , def , data , JSON .stringify (this )); }
33+ TryEvaluateNumber = function (exp , def , data ) { return DotNet .invokeMethod ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateNumber' , exp , def , data , JSON .stringify (this )); }
34+ TryEvaluateBool = function (exp , def , data ) { return DotNet .invokeMethod ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateBool' , exp , def , data , JSON .stringify (this )); }
35+ TryEvaluateDateTime = function (exp , def , data ) { return DotNet .invokeMethod ('ToolGood.Algorithm.WebAssembly' , 'TryEvaluateDateTime' , exp , def , data , JSON .stringify (this )); }
8936 } ();
9037
91-
9238 window.onload = async function () {
9339 await Blazor .start ();
94- r = await AlgorithmEngine .TryEvaluateString (" 'S' & 1" , " " )
40+ r = AlgorithmEngine .TryEvaluateString (" 'S' & 1" , " " )
9541 alert (" 'S' & 1 =>" + r );
96- r = await AlgorithmEngine .TryEvaluateNumber (" 1+2" , 0 )
42+ r = AlgorithmEngine .TryEvaluateNumber (" 1+2" , 0 )
9743 alert (" 1+2 =>" + r );
98- r = await AlgorithmEngine .TryEvaluateBool (" 1=1" , false )
44+ r = AlgorithmEngine .TryEvaluateBool (" 1=1" , false )
9945 alert (" 1=1 =>" + r );
100- r = await AlgorithmEngine .TryEvaluateDateTime (" date(2014,1,2)" , '2024-01-11' )
46+ r = AlgorithmEngine .TryEvaluateDateTime (" date(2014,1,2)" , '2024-01-11' )
10147 alert ('date(2014,1,2) =>' + r );
10248 } ;
10349 </pre >
10450</body >
10551<script src =" _framework/blazor.webassembly.js" autostart =" false" ></script >
10652<script >
107- AreaUnitType = new class {
108- constructor () {
109- this .MM2 = 11 ;
110- this .CM2 = 12 ;
111- this .DM2 = 13 ;
112- this .M2 = 14 ;
113- this .KM2 = 15 ;
114- }
115- }();
116- DistanceUnitType = new class {
117- constructor () {
118- this .MM = 1 ;
119- this .CM = 2 ;
120- this .DM = 3 ;
121- this .M = 4 ;
122- this .KM = 5 ;
123- }
124- }();
125- MassUnitType = new class {
126- constructor () {
127- this .G = 31 ;
128- this .KG = 32 ;
129- this .T = 33 ;
130- }
131- }();
132- VolumeUnitType = new class {
133- constructor () {
134- this .MM3 = 21 ;
135- this .CM3 = 22 ;
136- this .DM3 = 23 ;
137- this .M3 = 24 ;
138- this .KM3 = 25 ;
139- }
140- }();
53+ DistanceUnitType = new class { constructor () { this .MM = 1 ; this .CM = 2 ; this .DM = 3 ; this .M = 4 ; this .KM = 5 ; } }();
54+ AreaUnitType = new class { constructor () { this .MM2 = 11 ; this .CM2 = 12 ; this .DM2 = 13 ; this .M2 = 14 ; this .KM2 = 15 ; } }();
55+ VolumeUnitType = new class { constructor () { this .MM3 = 21 ; this .CM3 = 22 ; this .DM3 = 23 ; this .M3 = 24 ; this .KM3 = 25 ; } }();
56+ MassUnitType = new class { constructor () { this .G = 31 ; this .KG = 32 ; this .T = 33 ; } }();
14157 AlgorithmEngine = new class {
14258 constructor () {
14359 this .UseExcelIndex = true ;
@@ -149,45 +65,21 @@ AreaUnitType = new class {
14965 this .MassUnit = MassUnitType .KG ;
15066 this .IgnoreCase = false ;
15167 }
152-
153- createOption = function () {
154- var data = {
155- UseExcelIndex: this .UseExcelIndex ,
156- UseTempDict: this .UseTempDict ,
157- UseLocalTime: this .UseLocalTime ,
158- DistanceUnit: this .DistanceUnit ,
159- AreaUnit: this .AreaUnit ,
160- VolumeUnit: this .VolumeUnit ,
161- MassUnit: this .MassUnit ,
162- IgnoreCase: this .IgnoreCase ,
163- }
164- return JSON .stringify (data);
165- }
166-
167- TryEvaluateString = async function (exp , def , data ) {
168- return await DotNet .invokeMethodAsync (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateString' , exp, def, data, this .createOption ());
169- }
170- TryEvaluateNumber = async function (exp , def , data ) {
171- return await DotNet .invokeMethodAsync (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateNumber' , exp, def, data, this .createOption ());
172- }
173- TryEvaluateBool = async function (exp , def , data ) {
174- return await DotNet .invokeMethodAsync (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateBool' , exp, def, data, this .createOption ());
175- }
176- TryEvaluateDateTime = async function (exp , def , data ) {
177- return await DotNet .invokeMethodAsync (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateDateTime' , exp, def, data, this .createOption ());
178- }
68+ TryEvaluateString = function (exp , def , data ) { return DotNet .invokeMethod (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateString' , exp, def, data, JSON .stringify (this )); }
69+ TryEvaluateNumber = function (exp , def , data ) { return DotNet .invokeMethod (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateNumber' , exp, def, data, JSON .stringify (this )); }
70+ TryEvaluateBool = function (exp , def , data ) { return DotNet .invokeMethod (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateBool' , exp, def, data, JSON .stringify (this )); }
71+ TryEvaluateDateTime = function (exp , def , data ) { return DotNet .invokeMethod (' ToolGood.Algorithm.WebAssembly' , ' TryEvaluateDateTime' , exp, def, data, JSON .stringify (this )); }
17972 }();
18073
181-
18274 window .onload = async function () {
18375 await Blazor .start ();
184- r = await AlgorithmEngine .TryEvaluateString (" 'S' & 1" , " " )
76+ r = AlgorithmEngine .TryEvaluateString (" 'S' & 1" , " " )
18577 alert (" 'S' & 1 =>" + r);
186- r = await AlgorithmEngine .TryEvaluateNumber (" 1+2" , 0 )
78+ r = AlgorithmEngine .TryEvaluateNumber (" 1+2" , 0 )
18779 alert (" 1+2 =>" + r);
188- r = await AlgorithmEngine .TryEvaluateBool (" 1=1" , false )
80+ r = AlgorithmEngine .TryEvaluateBool (" 1=1" , false )
18981 alert (" 1=1 =>" + r);
190- r = await AlgorithmEngine .TryEvaluateDateTime (" date(2014,1,2)" , ' 2024-01-11' )
82+ r = AlgorithmEngine .TryEvaluateDateTime (" date(2014,1,2)" , ' 2024-01-11' )
19183 alert (' date(2014,1,2) =>' + r);
19284 };
19385 </script >
0 commit comments