mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-15 05:56:34 +08:00
修复了条件表达式".xxx<bool> = true/false"执行了错误分支,优化了流程的运行。
This commit is contained in:
@@ -18,20 +18,22 @@ namespace Serein.Library.Utils.SereinExpression.Resolver
|
||||
|
||||
public Operator Op { get; set; }
|
||||
public bool Value { get; set; }
|
||||
public bool Data { get; set; }
|
||||
|
||||
public override bool Evaluate(object obj)
|
||||
{
|
||||
|
||||
if (obj is bool boolObj)
|
||||
{
|
||||
return boolObj == Value;
|
||||
/*switch (Op)
|
||||
{
|
||||
case Operator.Is:
|
||||
return boolObj == Value;
|
||||
}*/
|
||||
}
|
||||
return false;
|
||||
return Value.Equals(Data);
|
||||
//if (obj is bool boolObj && Value is bool boolValue)
|
||||
//{
|
||||
|
||||
// /*switch (Op)
|
||||
// {
|
||||
// case Operator.Is:
|
||||
// return boolObj == Value;
|
||||
// }*/
|
||||
//}
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Utils.SereinExpression.Resolver
|
||||
@@ -24,14 +25,15 @@ namespace Serein.Library.Utils.SereinExpression.Resolver
|
||||
|
||||
if (TargetObj is T typedObj)
|
||||
{
|
||||
return new ValueTypeConditionResolver<T>
|
||||
var res = new ValueTypeConditionResolver<T>
|
||||
{
|
||||
RangeStart = RangeStart,
|
||||
RangeEnd = RangeEnd,
|
||||
Op = Op,
|
||||
Value = Value,
|
||||
ArithmeticExpression = ArithmeticExpression,
|
||||
}.Evaluate(typedObj);
|
||||
};
|
||||
return res.Evaluate(typedObj);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,12 +317,23 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
#region 解析类型 bool
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
return new MemberConditionResolver<bool>
|
||||
bool targetData = false;
|
||||
if (targetObj is bool tmp)
|
||||
{
|
||||
//MemberPath = memberPath,
|
||||
TargetObj = targetObj,
|
||||
Op = (ValueTypeConditionResolver<bool>.Operator)ParseBoolOperator(operatorStr)
|
||||
targetData = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObj = bool.Parse(targetObj.ToString());
|
||||
}
|
||||
return new BoolConditionResolver
|
||||
{
|
||||
//Value = bool.Parse(targetObj.ToString()),
|
||||
Value = bool.Parse(valueStr),
|
||||
Data = targetData,
|
||||
Op = BoolConditionResolver.Operator.Is
|
||||
};
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 解析类型 string
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -483,6 +484,10 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
tempType = typeof(string);
|
||||
break;
|
||||
case "datetime":
|
||||
if(valueStr.Equals("now", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return DateTime.Now;
|
||||
}
|
||||
tempType = typeof(DateTime);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user