mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-19 16:06:33 +08:00
重新优化了NodeModel类;从硬编码类型改为“注册/获取”的方式,为下一步解耦Workbench与节点UI做准备。
新增了“全局数据节点”;保存项目文件时,不同节点可以使用自定义数据保存自身独特的数据,不再借用“方法参数”。 重新设计了运行时的环境输出;增量式生成器现在可以选择在属性变更的前后时间点插入自定义代码;重写了加载项目、保存项目的方法。
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Library.Utils.SereinExpression;
|
||||
using System.Dynamic;
|
||||
using System.Reactive;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
@@ -25,6 +26,11 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
public partial class SingleExpOpNode : NodeModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 表达式参数索引
|
||||
/// </summary>
|
||||
private const int INDEX_EXPRESSION = 0;
|
||||
|
||||
public SingleExpOpNode(IFlowEnvironment environment) : base(environment)
|
||||
{
|
||||
|
||||
@@ -35,23 +41,46 @@ namespace Serein.NodeFlow.Model
|
||||
/// </summary>
|
||||
public override void OnCreating()
|
||||
{
|
||||
var pd = new ParameterDetails
|
||||
// 这里的这个参数是为了方便使用入参控制点,参数无意义
|
||||
var pd = new ParameterDetails[1];
|
||||
pd[INDEX_EXPRESSION] = new ParameterDetails
|
||||
{
|
||||
Index = 0,
|
||||
Index = INDEX_EXPRESSION,
|
||||
Name = nameof(Expression),
|
||||
DataType = typeof(string),
|
||||
ExplicitType = typeof(string),
|
||||
IsExplicitData = false,
|
||||
DataValue = string.Empty,
|
||||
DataType = typeof(string),
|
||||
ExplicitType = typeof(string),
|
||||
ArgDataSourceNodeGuid = string.Empty,
|
||||
ArgDataSourceType = ConnectionArgSourceType.GetPreviousNodeData,
|
||||
NodeModel = this,
|
||||
Convertor = null,
|
||||
ExplicitTypeName = "Value",
|
||||
Items = Array.Empty<string>(),
|
||||
Items = null,
|
||||
};
|
||||
this.MethodDetails.ParameterDetailss = [.. pd];
|
||||
}
|
||||
|
||||
this.MethodDetails.ParameterDetailss = new ParameterDetails[] { pd };
|
||||
/// <summary>
|
||||
/// 导出方法信息
|
||||
/// </summary>
|
||||
/// <param name="nodeInfo"></param>
|
||||
/// <returns></returns>
|
||||
public override NodeInfo SaveCustomData(NodeInfo nodeInfo)
|
||||
{
|
||||
dynamic data = new ExpandoObject();
|
||||
data.Expression = Expression ?? "";
|
||||
nodeInfo.CustomData = data;
|
||||
return nodeInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载自定义数据
|
||||
/// </summary>
|
||||
/// <param name="nodeInfo"></param>
|
||||
public override void LoadCustomData(NodeInfo nodeInfo)
|
||||
{
|
||||
this.Expression = nodeInfo.CustomData?.Expression ?? "";
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +105,6 @@ namespace Serein.NodeFlow.Model
|
||||
parameter = context.TransmissionData(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var newData = SerinExpressionEvaluator.Evaluate(Expression, parameter, out bool isChange);
|
||||
@@ -103,33 +130,5 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
}
|
||||
|
||||
public override ParameterData[] GetParameterdatas()
|
||||
{
|
||||
return [new ParameterData {
|
||||
Value = Expression,
|
||||
SourceNodeGuid = this.MethodDetails.ParameterDetailss[0].ArgDataSourceNodeGuid,
|
||||
SourceType = this.MethodDetails.ParameterDetailss[0].ArgDataSourceType.ToString(),
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override NodeModelBase LoadInfo(NodeInfo nodeInfo)
|
||||
{
|
||||
var node = this;
|
||||
node.Guid = nodeInfo.Guid;
|
||||
this.Position = nodeInfo.Position;// 加载位置信息
|
||||
|
||||
var pdInfo1 = nodeInfo.ParameterData[0];
|
||||
node.Expression = pdInfo1.Value; // 加载表达式
|
||||
|
||||
for (int i = 0; i < nodeInfo.ParameterData.Length; i++)
|
||||
{
|
||||
ParameterData? pd = nodeInfo.ParameterData[i];
|
||||
node.MethodDetails.ParameterDetailss[i].ArgDataSourceNodeGuid = pd.SourceNodeGuid;
|
||||
node.MethodDetails.ParameterDetailss[i].ArgDataSourceType = EnumHelper.ConvertEnum<ConnectionArgSourceType>(pd.SourceType);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user