2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.Library.Api;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.Library.Entity;
|
2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.Library.Enums;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.NodeFlow.Base;
|
2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.NodeFlow.Tool.SerinExpression;
|
2024-08-06 16:09:46 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Serein.NodeFlow.Model
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Expression Operation - 表达式操作
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public class SingleExpOpNode : NodeModelBase
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表达式
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Expression { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-12 20:32:54 +08:00
|
|
|
|
public override object? Execute(IDynamicContext context)
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
var data = PreviousNode?.FlowData;
|
|
|
|
|
|
|
|
|
|
|
|
var newData = SerinExpressionEvaluator.Evaluate(Expression, data, out bool isChange);
|
|
|
|
|
|
|
2024-09-09 16:42:01 +08:00
|
|
|
|
FlowState = FlowStateType.Succeed;
|
2024-08-06 16:09:46 +08:00
|
|
|
|
Console.WriteLine(newData);
|
|
|
|
|
|
if (isChange)
|
|
|
|
|
|
{
|
|
|
|
|
|
return newData;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return PreviousNode?.FlowData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
public override Parameterdata[] GetParameterdatas()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (base.MethodDetails.ExplicitDatas.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return MethodDetails.ExplicitDatas
|
|
|
|
|
|
.Select(it => new Parameterdata
|
|
|
|
|
|
{
|
|
|
|
|
|
state = it.IsExplicitData,
|
|
|
|
|
|
// value = it.DataValue,
|
|
|
|
|
|
expression = Expression,
|
|
|
|
|
|
})
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return [];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-06 16:09:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|