2024-10-20 12:10:57 +08:00
|
|
|
|
using Serein.Library.Api;
|
2024-10-27 00:54:10 +08:00
|
|
|
|
using Serein.Library.Utils;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
using System;
|
2024-11-02 16:48:40 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Serein.Library
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 节点入参参数详情
|
|
|
|
|
|
/// </summary>
|
2024-10-22 00:13:13 +08:00
|
|
|
|
[NodeProperty(ValuePath = NodeValuePath.Parameter)]
|
2024-10-20 12:10:57 +08:00
|
|
|
|
public partial class ParameterDetails
|
|
|
|
|
|
{
|
2024-11-02 16:48:40 +08:00
|
|
|
|
// private readonly IFlowEnvironment env;
|
2024-10-23 19:22:27 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// 所在的节点
|
2024-10-23 19:22:27 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo(IsProtection = true)]
|
|
|
|
|
|
private NodeModelBase _nodeModel;
|
|
|
|
|
|
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 参数索引
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private int _index;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// <para>是否为显式参数(固定值/表达式)</para>
|
|
|
|
|
|
/// <para>如果为 true ,则使用UI输入的文本值作为入参数据(过程中会尽可能转为类型需要的数据)。</para>
|
|
|
|
|
|
/// <para>如果为 false ,则根据 ArgDataSourceType 调用相应节点的GetFlowData()方法,获取返回的数据作为入参数据。</para>
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo(IsNotification = true)]
|
|
|
|
|
|
private bool _isExplicitData ;
|
|
|
|
|
|
|
2024-12-14 23:46:37 +08:00
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 转换器 IEnumConvertor<,>
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
//[PropertyInfo]
|
|
|
|
|
|
//private Func<object, object> _convertor ;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// 方法入参若无相关转换器特性标注,则无需关注该变量。该变量用于需要用到枚举BinValue转换器时,指示相应的入参变量需要转为的类型。
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private Type _explicitType ;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 目前存在三种状态:Select/Bool/Value
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// <para>Select : 枚举值/可选值</para>
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// <para>Bool : 布尔类型</para>
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// <para>Value :除以上类型之外的任意参数</para>
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private string _explicitTypeName ;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// 入参数据来源。默认使用上一节点作为入参数据。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo(IsNotification = true)]
|
|
|
|
|
|
private ConnectionArgSourceType _argDataSourceType = ConnectionArgSourceType.GetPreviousNodeData;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当 ArgDataSourceType 不为 GetPreviousNodeData 时(从运行时上一节点获取数据)。
|
2024-10-27 00:54:10 +08:00
|
|
|
|
/// 则通过当前上下文,获取该Guid对应的数据作为预处理的入参参数。
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// </summary>
|
2024-10-27 00:54:10 +08:00
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private string _argDataSourceNodeGuid;
|
2024-10-24 23:32:43 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 方法入参需要的类型。
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private Type _dataType ;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 方法入参参数名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private string _name ;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 自定义的方法入参数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo(IsNotification = true)] // IsPrint = true
|
|
|
|
|
|
private string _dataValue;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// 只有当ExplicitTypeName 为 Select 时,才会需要该成员。
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo(IsNotification = true)]
|
|
|
|
|
|
private string[] _items ;
|
2024-11-02 16:48:40 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 指示该属性是可变参数的其中一员(可变参数为数组类型)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[PropertyInfo]
|
|
|
|
|
|
private bool _isParams;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public partial class ParameterDetails
|
|
|
|
|
|
{
|
2024-10-27 00:54:10 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用于创建元数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ParameterDetails()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-02 16:48:40 +08:00
|
|
|
|
|
2024-10-27 00:54:10 +08:00
|
|
|
|
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 为节点实例化新的入参描述
|
|
|
|
|
|
/// </summary>
|
2024-11-02 16:48:40 +08:00
|
|
|
|
public ParameterDetails(NodeModelBase nodeModel)
|
2024-10-20 12:10:57 +08:00
|
|
|
|
{
|
2024-10-23 19:22:27 +08:00
|
|
|
|
this.NodeModel = nodeModel;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
}
|
2024-10-24 23:32:43 +08:00
|
|
|
|
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通过参数信息加载实体,用于加载项目文件、远程连接的场景
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="info">参数信息</param>
|
|
|
|
|
|
public ParameterDetails(ParameterDetailsInfo info)
|
|
|
|
|
|
{
|
|
|
|
|
|
Index = info.Index;
|
|
|
|
|
|
Name = info.Name;
|
|
|
|
|
|
DataType = Type.GetType(info.DataTypeFullName);
|
|
|
|
|
|
ExplicitType = Type.GetType(info.ExplicitTypeFullName);
|
|
|
|
|
|
ExplicitTypeName = info.ExplicitTypeName;
|
|
|
|
|
|
Items = info.Items;
|
2024-11-02 22:11:38 +08:00
|
|
|
|
IsParams = info.IsParams;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 转为描述
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public ParameterDetailsInfo ToInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new ParameterDetailsInfo
|
|
|
|
|
|
{
|
2024-10-27 00:54:10 +08:00
|
|
|
|
Index = this.Index,
|
2024-11-02 22:11:38 +08:00
|
|
|
|
IsParams = this.IsParams,
|
2024-10-27 00:54:10 +08:00
|
|
|
|
DataTypeFullName = this.DataType.FullName,
|
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
|
ExplicitTypeFullName = this.ExplicitType.FullName,
|
|
|
|
|
|
ExplicitTypeName = this.ExplicitTypeName,
|
|
|
|
|
|
Items = this.Items.Select(it => it).ToArray(),
|
2024-10-20 12:10:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// 为某个节点从元数据中拷贝方法描述的入参描述
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// </summary>
|
2024-10-27 00:54:10 +08:00
|
|
|
|
/// <param name="nodeModel">对应的节点</param>
|
2024-10-20 12:10:57 +08:00
|
|
|
|
/// <returns></returns>
|
2024-11-02 16:48:40 +08:00
|
|
|
|
public ParameterDetails CloneOfModel(NodeModelBase nodeModel)
|
2024-10-20 12:10:57 +08:00
|
|
|
|
{
|
2024-11-02 16:48:40 +08:00
|
|
|
|
var pd = new ParameterDetails(nodeModel)
|
2024-10-20 12:10:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
Index = this.Index,
|
|
|
|
|
|
IsExplicitData = this.IsExplicitData,
|
|
|
|
|
|
ExplicitType = this.ExplicitType,
|
|
|
|
|
|
ExplicitTypeName = this.ExplicitTypeName,
|
2024-12-14 23:46:37 +08:00
|
|
|
|
//Convertor = this.Convertor,
|
2024-10-20 12:10:57 +08:00
|
|
|
|
DataType = this.DataType,
|
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
|
DataValue = string.IsNullOrEmpty(DataValue) ? string.Empty : DataValue,
|
|
|
|
|
|
Items = this.Items?.Select(it => it).ToArray(),
|
2024-11-02 22:11:38 +08:00
|
|
|
|
IsParams = this.IsParams,
|
2024-10-24 23:32:43 +08:00
|
|
|
|
|
2024-10-20 12:10:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
return pd;
|
|
|
|
|
|
}
|
2024-10-28 15:21:08 +08:00
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"[{this.Index}] {this.Name} : {this.ExplicitType.FullName} -> {this.DataType.FullName}";
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|