mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
新增了NodeParamAttribute特性,用来指示类库节点的行为
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Serein.Library
|
|||||||
/// <para>表示该类中存在节点信息</para>
|
/// <para>表示该类中存在节点信息</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class DynamicFlowAttribute : Attribute
|
public sealed class DynamicFlowAttribute : Attribute
|
||||||
{
|
{
|
||||||
public DynamicFlowAttribute(string name = "",bool scan = true)
|
public DynamicFlowAttribute(string name = "",bool scan = true)
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ namespace Serein.Library
|
|||||||
/// <para>如果是Task类型的返回值,将会自动进行等待</para>
|
/// <para>如果是Task类型的返回值,将会自动进行等待</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||||
public class NodeActionAttribute : Attribute
|
public sealed class NodeActionAttribute : Attribute
|
||||||
{
|
{
|
||||||
public NodeActionAttribute(NodeType methodDynamicType,
|
public NodeActionAttribute(NodeType methodDynamicType,
|
||||||
string methodTips = "",
|
string methodTips = "",
|
||||||
@@ -113,17 +113,25 @@ namespace Serein.Library
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 节点参数设置
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public sealed class NodeParamAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 显示名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
//[AttributeUsage(AttributeTargets.Field)]
|
/// <summary>
|
||||||
//public class BindTypeAttribute : Attribute
|
/// 是否显式设置(此设置对于有入参默认值的参数无效)
|
||||||
//{
|
/// </summary>
|
||||||
// public Type Type { get; }
|
public bool IsExplicit;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// public BindTypeAttribute(Type type)
|
|
||||||
// {
|
|
||||||
// Type = type;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||||
public class BindValueAttribute : Attribute
|
public class BindValueAttribute : Attribute
|
||||||
@@ -136,6 +144,8 @@ namespace Serein.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 枚举值转换器,要求枚举项标记的BindValueAttribute特性,与搭配的参数类型一致,否则参数不会传入
|
/// 枚举值转换器,要求枚举项标记的BindValueAttribute特性,与搭配的参数类型一致,否则参数不会传入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,51 +17,11 @@ namespace Serein.Library
|
|||||||
[DynamicFlow(Name ="[基础功能]")]
|
[DynamicFlow(Name ="[基础功能]")]
|
||||||
public class SereinBaseFunction
|
public class SereinBaseFunction
|
||||||
{
|
{
|
||||||
//[NodeAction(NodeType.Action,"条件节点")]
|
|
||||||
//private bool SereinConditionNode(IDynamicContext context,
|
|
||||||
// object targetObject,
|
|
||||||
// string exp = "ISPASS")
|
|
||||||
//{
|
|
||||||
// var isPass = SereinConditionParser.To(targetObject, exp);
|
|
||||||
// context.NextOrientation = isPass ? ConnectionInvokeType.IsSucceed : ConnectionInvokeType.IsFail;
|
|
||||||
// return isPass;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//[NodeAction(NodeType.Action, "表达式节点")]
|
|
||||||
//private object SereinExpNode(IDynamicContext context,
|
|
||||||
// object targetObject,
|
|
||||||
// string exp)
|
|
||||||
//{
|
|
||||||
|
|
||||||
// exp = "@" + exp;
|
|
||||||
// var newData = SerinExpressionEvaluator.Evaluate(exp, targetObject, out bool isChange);
|
|
||||||
// object result;
|
|
||||||
// if (isChange || exp.StartsWith("@GET",System.StringComparison.OrdinalIgnoreCase))
|
|
||||||
// {
|
|
||||||
// result = newData;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// result = targetObject;
|
|
||||||
// }
|
|
||||||
// context.NextOrientation = ConnectionInvokeType.IsSucceed;
|
|
||||||
// return result;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[NodeAction(NodeType.Action, "键值对组装")]
|
[NodeAction(NodeType.Action, "键值对组装")]
|
||||||
private Dictionary<string, object> SereinKvDataCollectionNode(/*NodeModelBase nodeModel, */
|
private Dictionary<string, object> SereinKvDataCollectionNode(string argName,
|
||||||
string argName,
|
|
||||||
params object[] value)
|
params object[] value)
|
||||||
{
|
{
|
||||||
//var paramsArgIndex = nodeModel.MethodDetails.ParamsArgIndex;
|
|
||||||
//var pds = nodeModel.MethodDetails.ParameterDetailss;
|
|
||||||
//var length = pds.Length - paramsArgIndex;
|
|
||||||
//for(int i = paramsArgIndex; i < pds.Length; i++)
|
|
||||||
//{
|
|
||||||
// var pd = pds[i];
|
|
||||||
//}
|
|
||||||
|
|
||||||
var names = argName.Split(';');
|
var names = argName.Split(';');
|
||||||
var count = Math.Min(value.Length, names.Length);
|
var count = Math.Min(value.Length, names.Length);
|
||||||
@@ -90,7 +50,9 @@ namespace Serein.Library
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NodeAction(NodeType.Action, "逻辑分支")]
|
[NodeAction(NodeType.Action, "逻辑分支")]
|
||||||
private object SereinLogicalBranch(bool @bool, object t_value,object f_value)
|
private object SereinLogicalBranch([NodeParam(IsExplicit = false)]bool @bool,
|
||||||
|
object t_value,
|
||||||
|
object f_value)
|
||||||
{
|
{
|
||||||
return @bool ? t_value : f_value;
|
return @bool ? t_value : f_value;
|
||||||
}
|
}
|
||||||
@@ -141,7 +103,7 @@ namespace Serein.Library
|
|||||||
|
|
||||||
|
|
||||||
[NodeAction(NodeType.Action, "设置/更新全局数据")]
|
[NodeAction(NodeType.Action, "设置/更新全局数据")]
|
||||||
private object SereinAddOrUpdateFlowGlobalData(string name,object data)
|
private object SereinAddOrUpdateFlowGlobalData(string name, object data)
|
||||||
{
|
{
|
||||||
SereinEnv.AddOrUpdateFlowGlobalData(name, data);
|
SereinEnv.AddOrUpdateFlowGlobalData(name, data);
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public static class NodeMethodDetailsHelper
|
|||||||
#endregion
|
#endregion
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
foreach(var pd in tempParams)
|
/* foreach(var pd in tempParams)
|
||||||
{
|
{
|
||||||
var argType = pd.DataType;
|
var argType = pd.DataType;
|
||||||
// 运行环境
|
// 运行环境
|
||||||
@@ -285,9 +285,8 @@ public static class NodeMethodDetailsHelper
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pd.IsExplicitData = true;
|
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return tempParams;
|
return tempParams;
|
||||||
}
|
}
|
||||||
@@ -311,7 +310,26 @@ public static class NodeMethodDetailsHelper
|
|||||||
{
|
{
|
||||||
dataType = parameterInfo.ParameterType;
|
dataType = parameterInfo.ParameterType;
|
||||||
}
|
}
|
||||||
var description = parameterInfo.GetCustomAttribute<DescriptionAttribute>()?.Description ?? "";
|
isExplicitData = true;
|
||||||
|
string description = string.Empty; // 入参描述
|
||||||
|
var nodeParmsAttribute = parameterInfo.GetCustomAttribute<NodeParamAttribute>();
|
||||||
|
if(nodeParmsAttribute is not null)
|
||||||
|
{
|
||||||
|
if (!parameterInfo.HasDefaultValue)
|
||||||
|
{
|
||||||
|
isExplicitData = nodeParmsAttribute.IsExplicit; // 设置是否是显式参数
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(nodeParmsAttribute.Name))
|
||||||
|
{
|
||||||
|
description = nodeParmsAttribute.Name; // 设置显示的名称
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
description = parameterInfo.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty; // 判断是否存在注释特性
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var inputType = GetInputType(explicitParemType);
|
var inputType = GetInputType(explicitParemType);
|
||||||
var items = GetExplicitItems(explicitParemType, inputType);
|
var items = GetExplicitItems(explicitParemType, inputType);
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ namespace Serein.Workbench.Services
|
|||||||
/// <param name="keyEventService"></param>
|
/// <param name="keyEventService"></param>
|
||||||
/// <param name="flowNodeService"></param>
|
/// <param name="flowNodeService"></param>
|
||||||
public WorkbenchEventService(IFlowEnvironment flowEnvironment,
|
public WorkbenchEventService(IFlowEnvironment flowEnvironment,
|
||||||
IFlowEEForwardingService flowEEForwardingService,
|
IFlowEEForwardingService flowEEForwardingService,
|
||||||
IKeyEventService keyEventService,
|
IKeyEventService keyEventService,
|
||||||
FlowNodeService flowNodeService)
|
FlowNodeService flowNodeService)
|
||||||
{
|
{
|
||||||
this.flowEnvironment = flowEnvironment;
|
this.flowEnvironment = flowEnvironment;
|
||||||
this.flowEEForwardingService = flowEEForwardingService;
|
this.flowEEForwardingService = flowEEForwardingService;
|
||||||
@@ -81,11 +81,17 @@ namespace Serein.Workbench.Services
|
|||||||
|
|
||||||
private void InitEvents()
|
private void InitEvents()
|
||||||
{
|
{
|
||||||
|
flowEEForwardingService.OnProjectLoaded += FlowEEForwardingService_OnProjectLoaded;
|
||||||
flowEEForwardingService.OnProjectSaving += SaveProjectToLocalFile;
|
flowEEForwardingService.OnProjectSaving += SaveProjectToLocalFile;
|
||||||
flowEEForwardingService.OnEnvOut += FlowEEForwardingService_OnEnvOut;
|
flowEEForwardingService.OnEnvOut += FlowEEForwardingService_OnEnvOut;
|
||||||
keyEventService.OnKeyDown += KeyEventService_OnKeyDown; ;
|
keyEventService.OnKeyDown += KeyEventService_OnKeyDown; ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FlowEEForwardingService_OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void KeyEventService_OnKeyDown(System.Windows.Input.Key key)
|
private void KeyEventService_OnKeyDown(System.Windows.Input.Key key)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user