Skip to content

Commit d145086

Browse files
Continue Working
1 parent 65028c1 commit d145086

3 files changed

Lines changed: 142 additions & 70 deletions

File tree

EZCode/EZHelp.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public object ObjectParse(object obj, object type, bool to_string)
141141
{
142142
if (int.TryParse(obj.ToString(), out int i)) return i;
143143
if (float.TryParse(obj.ToString(), out float f)) return f;
144+
try { obj = Operate(obj.ToString(), false); } catch { }
145+
try { obj = Evaluate(obj.ToString()); } catch { }
144146
}
145147
return obj;
146148
}
@@ -158,13 +160,14 @@ public bool Evaluate(string expression)
158160

159161
return (bool)row["expression"];
160162
}
161-
public float Operate(string expression)
163+
public float Operate(string expression) => Operate(expression, true);
164+
public float Operate(string expression, bool object_parse)
162165
{
163-
string[] parts = SplitWithDelimiters(ObjectParse(expression, "str").ToString(), ['-', '+', '=', '*', '/', '%', '&', '|', '!', ' ']).Where(x => x != "" && x != " ").ToArray();
166+
string[] parts = SplitWithDelimiters(object_parse ? (ObjectParse(expression, "str").ToString()) : expression, ['-', '+', '=', '*', '/', '%', '&', '|', '!', ' ']).Where(x => x != "" && x != " ").ToArray();
164167
expression = "";
165168
foreach (string e in parts)
166169
{
167-
expression += ObjectParse(e, "float").ToString() + " ";
170+
expression += object_parse ? (ObjectParse(e, "float").ToString() + " ") : e + " ";
168171
}
169172
DataTable table = new DataTable();
170173
table.Columns.Add("expression", typeof(string), expression);

0 commit comments

Comments
 (0)