简单表达式计算就用DataTable自带的好了

This commit is contained in:
艾竹
2023-01-07 12:08:28 +08:00
parent 93ca2859ba
commit 8fc69bc96d
2 changed files with 12 additions and 11 deletions

View File

@@ -5,7 +5,10 @@ using System.Linq;
using System.Windows;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using Expression = org.mariuszgromada.math.mxparser.Expression;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Data;
namespace AIStudio.Wpf.Flowchart
{
@@ -274,17 +277,19 @@ namespace AIStudio.Wpf.Flowchart
try
{
//按条件选择一个分支
string express = step.Value.Replace("data.Flag", nextNode.Text);
Expression e = new Expression(express);
var result = e.calculate();
if (result == 1)
string expression = step.Value.Replace("data.Flag", nextNode.Text);
var result = new DataTable().Compute(expression, "");
if (result.Equals(true))
{
SetStatus(nextNode, 100);
Next(step.Key, nextNode);
return;
}
}
catch { }
catch(Exception ex)
{
}
}
//如果表达式错了,就按第一个处理
Next(nextNode.SelectNextStep.FirstOrDefault().Key, nextNode);
@@ -367,6 +372,6 @@ namespace AIStudio.Wpf.Flowchart
public static void DisposeData(IDiagramViewModel viewModel)
{
FlowNodes.Remove(viewModel);
}
}
}
}