mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-02 15:50:47 +08:00
调整了Library文件结构;
源代码生成新增了参数验证方法; 修改了ParamterDetails的定义
This commit is contained in:
13
Library/Api/IEnumConvertor.cs
Normal file
13
Library/Api/IEnumConvertor.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace Serein.Library.Api
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 枚举转换器接口
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TEnum"></typeparam>
|
||||||
|
/// <typeparam name="TValue"></typeparam>
|
||||||
|
public interface IEnumConvertor<TEnum, TValue>
|
||||||
|
{
|
||||||
|
TValue Convertor(TEnum e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
17
Library/Attributes/AutoInjectionAttribute.cs
Normal file
17
Library/Attributes/AutoInjectionAttribute.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示该属性为自动注入依赖项。</para>
|
||||||
|
/// <para>使用场景:构造函数中存在互相依赖的情况</para>
|
||||||
|
/// <para>例如ServiceA类构造函数中需要传入ServiceB,ServiceB类构造函数中也需要传入ServiceA</para>
|
||||||
|
/// <para>这种情况会导致流程启动时,IOC容器无法注入构造函数并创建类型,导致启动失败。</para>
|
||||||
|
/// <para>解决方法:从ServiceA类的构造函数中移除ServiceB类型的入参,将该类型更改为公开可见的可写属性成员ServiceB serviceB{get;set;},并在该属性上标记[AutoInjection]特性</para>
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
||||||
|
public sealed class AutoInjectionAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
Library/Attributes/AutoRegisterAttribute.cs
Normal file
26
Library/Attributes/AutoRegisterAttribute.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Serein.Library;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>启动流程时,会将标记了该特性的类自动注册到IOC容器中,从而无需手动进行注册绑定。</para>
|
||||||
|
/// <para>流程启动后,IOC容器会进行5次注册绑定。</para>
|
||||||
|
/// <para>第1次注册绑定:初始化所有节点所属的类([DynamicFlow]标记的类)。</para>
|
||||||
|
/// <para>第2次注册绑定:※初始化所有[AutoRegister(Class=FlowInit)]的类。</para>
|
||||||
|
/// <para>第3次注册绑定:调用所有Init节点后,进行注册绑定。</para>
|
||||||
|
/// <para>第4次注册绑定:※初始化所有[AutoRegister(Class=FlowLoading)]的类</para>
|
||||||
|
/// <para>第5次注册绑定:调用所有Load节点后,进行注册绑定。</para>
|
||||||
|
/// <para>需要注意的是,在第1次进行注册绑定的过程中,如果类的构造函数存在入参,那么也会将入参自动创建实例并托管到IOC容器中。</para>
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public sealed class AutoRegisterAttribute : Attribute
|
||||||
|
{
|
||||||
|
public AutoRegisterAttribute(RegisterSequence Class = RegisterSequence.FlowInit)
|
||||||
|
{
|
||||||
|
this.Class = Class;
|
||||||
|
}
|
||||||
|
public RegisterSequence Class ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
Library/Attributes/BindConvertorAttribute.cs
Normal file
21
Library/Attributes/BindConvertorAttribute.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定转换器
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public class BindConvertorAttribute : Attribute
|
||||||
|
{
|
||||||
|
public Type EnumType { get; }
|
||||||
|
public Type ConvertorType { get; }
|
||||||
|
|
||||||
|
public BindConvertorAttribute(Type @enum, Type convertor)
|
||||||
|
{
|
||||||
|
EnumType = @enum;
|
||||||
|
ConvertorType = convertor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
16
Library/Attributes/BindValueAttribute.cs
Normal file
16
Library/Attributes/BindValueAttribute.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||||
|
public class BindValueAttribute : Attribute
|
||||||
|
{
|
||||||
|
public object Value { get; }
|
||||||
|
|
||||||
|
public BindValueAttribute(object value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
28
Library/Attributes/DynamicFlowAttribute.cs
Normal file
28
Library/Attributes/DynamicFlowAttribute.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示该类中存在节点信息</para>
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public sealed class DynamicFlowAttribute : Attribute
|
||||||
|
{
|
||||||
|
public DynamicFlowAttribute(string name = "",bool scan = true)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Scan = scan;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 补充名称,不影响运行流程
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 如果设置为false,将忽略该类
|
||||||
|
/// </summary>
|
||||||
|
public bool Scan { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
Library/Attributes/EnumTypeConvertorAttribute.cs
Normal file
27
Library/Attributes/EnumTypeConvertorAttribute.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 枚举值转换器,要求枚举项标记的BindValueAttribute特性,与搭配的参数类型一致,否则参数不会传入
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public class EnumTypeConvertorAttribute : Attribute
|
||||||
|
{
|
||||||
|
public Type EnumType { get; }
|
||||||
|
|
||||||
|
public EnumTypeConvertorAttribute(Type @enum)
|
||||||
|
{
|
||||||
|
if (@enum.IsEnum)
|
||||||
|
{
|
||||||
|
EnumType = @enum;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("需要枚举类型");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
44
Library/Attributes/NodeActionAttribute.cs
Normal file
44
Library/Attributes/NodeActionAttribute.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示该方法将会生成节点,或是加入到流程运行中</para>
|
||||||
|
/// <para>如果是Task类型的返回值,将会自动进行等待</para>
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||||
|
public sealed class NodeActionAttribute : Attribute
|
||||||
|
{
|
||||||
|
public NodeActionAttribute(NodeType methodDynamicType,
|
||||||
|
string methodTips = "",
|
||||||
|
bool scan = true,
|
||||||
|
string lockName = "")
|
||||||
|
{
|
||||||
|
Scan = scan;
|
||||||
|
MethodDynamicType = methodDynamicType;
|
||||||
|
AnotherName = methodTips;
|
||||||
|
LockName = lockName;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 如果设置为false时将不会生成节点信息
|
||||||
|
/// </summary>
|
||||||
|
public bool Scan;
|
||||||
|
/// <summary>
|
||||||
|
/// 类似于注释的效果
|
||||||
|
/// </summary>
|
||||||
|
public string AnotherName;
|
||||||
|
/// <summary>
|
||||||
|
/// 标记节点行为
|
||||||
|
/// </summary>
|
||||||
|
public NodeType MethodDynamicType;
|
||||||
|
/// <summary>
|
||||||
|
/// 暂无意义
|
||||||
|
/// </summary>
|
||||||
|
public string LockName;
|
||||||
|
/// <summary>
|
||||||
|
/// 分组名称,暂无意义
|
||||||
|
/// </summary>
|
||||||
|
public string GroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
Library/Attributes/NodeParamAttribute.cs
Normal file
24
Library/Attributes/NodeParamAttribute.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 节点参数设置
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public sealed class NodeParamAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 显示名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显式设置(此设置对于有入参默认值的参数无效)
|
||||||
|
/// </summary>
|
||||||
|
public bool IsExplicit;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
Library/Enums/RegisterSequence.cs
Normal file
21
Library/Enums/RegisterSequence.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Serein.Library
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 注册顺序
|
||||||
|
/// </summary>
|
||||||
|
public enum RegisterSequence
|
||||||
|
{ /// <summary>
|
||||||
|
/// 不自动初始化
|
||||||
|
/// </summary>
|
||||||
|
Node,
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化后
|
||||||
|
/// </summary>
|
||||||
|
FlowInit,
|
||||||
|
/// <summary>
|
||||||
|
/// 加载后
|
||||||
|
/// </summary>
|
||||||
|
FlowLoading,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -72,7 +72,6 @@ namespace Serein.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[PropertyInfo]
|
[PropertyInfo]
|
||||||
private ParameterDetails[] _parameterDetailss;
|
private ParameterDetails[] _parameterDetailss;
|
||||||
//private List<ParameterDetails> _parameterDetailss;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>描述该方法是否存在可选参数</para>
|
/// <para>描述该方法是否存在可选参数</para>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Serein.Library
|
|||||||
/// <para>如果为 true ,则使用输入的文本值作为入参数据。</para>
|
/// <para>如果为 true ,则使用输入的文本值作为入参数据。</para>
|
||||||
/// <para>如果为 false ,则在当前流程上下文中,根据 ArgDataSourceNodeGuid 查找到对应节点,并根据 ArgDataSourceNodeGuid 判断如何获取其返回的数据,以此作为入参数据。</para>
|
/// <para>如果为 false ,则在当前流程上下文中,根据 ArgDataSourceNodeGuid 查找到对应节点,并根据 ArgDataSourceNodeGuid 判断如何获取其返回的数据,以此作为入参数据。</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PropertyInfo(IsNotification = true)]
|
[PropertyInfo(IsNotification = true, IsVerify = true)]
|
||||||
private bool _isExplicitData ;
|
private bool _isExplicitData ;
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@@ -160,18 +160,18 @@ namespace Serein.Library
|
|||||||
ExplicitType = Type.GetType(info.ExplicitTypeFullName);
|
ExplicitType = Type.GetType(info.ExplicitTypeFullName);
|
||||||
InputType = info.InputType.ConvertEnum<ParameterValueInputType>();
|
InputType = info.InputType.ConvertEnum<ParameterValueInputType>();
|
||||||
Items = info.Items;
|
Items = info.Items;
|
||||||
IsParams = info.IsParams;
|
IsParams = info.IsParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void BeforeTheIsExplicitData(ref bool __isAllow, bool newValue)
|
||||||
partial void OnIsExplicitDataChanged(bool oldValue, bool newValue)
|
|
||||||
{
|
{
|
||||||
if(DataType == typeof(IFlowContext))
|
if(DataType == typeof(IFlowContext))
|
||||||
{
|
{
|
||||||
|
__isAllow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 转为描述
|
/// 转为描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,202 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace Serein.Library
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// <para>表示该属性为自动注入依赖项。</para>
|
|
||||||
/// <para>使用场景:构造函数中存在互相依赖的情况</para>
|
|
||||||
/// <para>例如ServiceA类构造函数中需要传入ServiceB,ServiceB类构造函数中也需要传入ServiceA</para>
|
|
||||||
/// <para>这种情况会导致流程启动时,IOC容器无法注入构造函数并创建类型,导致启动失败。</para>
|
|
||||||
/// <para>解决方法:从ServiceA类的构造函数中移除ServiceB类型的入参,将该类型更改为公开可见的可写属性成员ServiceB serviceB{get;set;},并在该属性上标记[AutoInjection]特性</para>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
|
|
||||||
public sealed class AutoInjectionAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 注册顺序
|
|
||||||
/// </summary>
|
|
||||||
public enum RegisterSequence
|
|
||||||
{ /// <summary>
|
|
||||||
/// 不自动初始化
|
|
||||||
/// </summary>
|
|
||||||
Node,
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化后
|
|
||||||
/// </summary>
|
|
||||||
FlowInit,
|
|
||||||
/// <summary>
|
|
||||||
/// 加载后
|
|
||||||
/// </summary>
|
|
||||||
FlowLoading,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>启动流程时,会将标记了该特性的类自动注册到IOC容器中,从而无需手动进行注册绑定。</para>
|
|
||||||
/// <para>流程启动后,IOC容器会进行5次注册绑定。</para>
|
|
||||||
/// <para>第1次注册绑定:初始化所有节点所属的类([DynamicFlow]标记的类)。</para>
|
|
||||||
/// <para>第2次注册绑定:※初始化所有[AutoRegister(Class=FlowInit)]的类。</para>
|
|
||||||
/// <para>第3次注册绑定:调用所有Init节点后,进行注册绑定。</para>
|
|
||||||
/// <para>第4次注册绑定:※初始化所有[AutoRegister(Class=FlowLoading)]的类</para>
|
|
||||||
/// <para>第5次注册绑定:调用所有Load节点后,进行注册绑定。</para>
|
|
||||||
/// <para>需要注意的是,在第1次进行注册绑定的过程中,如果类的构造函数存在入参,那么也会将入参自动创建实例并托管到IOC容器中。</para>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public sealed class AutoRegisterAttribute : Attribute
|
|
||||||
{
|
|
||||||
public AutoRegisterAttribute(RegisterSequence Class = RegisterSequence.FlowInit)
|
|
||||||
{
|
|
||||||
this.Class = Class;
|
|
||||||
}
|
|
||||||
public RegisterSequence Class ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>表示该类中存在节点信息</para>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public sealed class DynamicFlowAttribute : Attribute
|
|
||||||
{
|
|
||||||
public DynamicFlowAttribute(string name = "",bool scan = true)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Scan = scan;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 补充名称,不影响运行流程
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 如果设置为false,将忽略该类
|
|
||||||
/// </summary>
|
|
||||||
public bool Scan { get; set; } = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>表示该方法将会生成节点,或是加入到流程运行中</para>
|
|
||||||
/// <para>如果是Task类型的返回值,将会自动进行等待</para>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
|
||||||
public sealed class NodeActionAttribute : Attribute
|
|
||||||
{
|
|
||||||
public NodeActionAttribute(NodeType methodDynamicType,
|
|
||||||
string methodTips = "",
|
|
||||||
bool scan = true,
|
|
||||||
string lockName = "")
|
|
||||||
{
|
|
||||||
Scan = scan;
|
|
||||||
MethodDynamicType = methodDynamicType;
|
|
||||||
AnotherName = methodTips;
|
|
||||||
LockName = lockName;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 如果设置为false时将不会生成节点信息
|
|
||||||
/// </summary>
|
|
||||||
public bool Scan;
|
|
||||||
/// <summary>
|
|
||||||
/// 类似于注释的效果
|
|
||||||
/// </summary>
|
|
||||||
public string AnotherName;
|
|
||||||
/// <summary>
|
|
||||||
/// 标记节点行为
|
|
||||||
/// </summary>
|
|
||||||
public NodeType MethodDynamicType;
|
|
||||||
/// <summary>
|
|
||||||
/// 暂无意义
|
|
||||||
/// </summary>
|
|
||||||
public string LockName;
|
|
||||||
/// <summary>
|
|
||||||
/// 分组名称,暂无意义
|
|
||||||
/// </summary>
|
|
||||||
public string GroupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 节点参数设置
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Parameter)]
|
|
||||||
public sealed class NodeParamAttribute : Attribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 显示名称
|
|
||||||
/// </summary>
|
|
||||||
public string Name;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否显式设置(此设置对于有入参默认值的参数无效)
|
|
||||||
/// </summary>
|
|
||||||
public bool IsExplicit;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
||||||
public class BindValueAttribute : Attribute
|
|
||||||
{
|
|
||||||
public object Value { get; }
|
|
||||||
|
|
||||||
public BindValueAttribute(object value)
|
|
||||||
{
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 枚举值转换器,要求枚举项标记的BindValueAttribute特性,与搭配的参数类型一致,否则参数不会传入
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Parameter)]
|
|
||||||
public class EnumTypeConvertorAttribute : Attribute
|
|
||||||
{
|
|
||||||
public Type EnumType { get; }
|
|
||||||
|
|
||||||
public EnumTypeConvertorAttribute(Type @enum)
|
|
||||||
{
|
|
||||||
if (@enum.IsEnum)
|
|
||||||
{
|
|
||||||
EnumType = @enum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException("需要枚举类型");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 绑定转换器
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Parameter)]
|
|
||||||
public class BindConvertorAttribute : Attribute
|
|
||||||
{
|
|
||||||
public Type EnumType { get; }
|
|
||||||
public Type ConvertorType { get; }
|
|
||||||
|
|
||||||
public BindConvertorAttribute(Type @enum, Type convertor)
|
|
||||||
{
|
|
||||||
this.EnumType = @enum;
|
|
||||||
this.ConvertorType = convertor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 枚举转换器接口
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TEnum"></typeparam>
|
|
||||||
/// <typeparam name="TValue"></typeparam>
|
|
||||||
public interface IEnumConvertor<TEnum, TValue>
|
|
||||||
{
|
|
||||||
TValue Convertor(TEnum e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Serein.Library
|
namespace Serein.Library
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 节点静态配置类
|
||||||
|
/// </summary>
|
||||||
public static class NodeStaticConfig
|
public static class NodeStaticConfig
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
using Microsoft.Extensions.ObjectPool;
|
using Serein.Library;
|
||||||
using Serein.Library;
|
|
||||||
using Serein.Library.Api;
|
using Serein.Library.Api;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Serein.NodeFlow
|
namespace Serein.NodeFlow
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
using Serein.Library;
|
using Serein.Library;
|
||||||
using Serein.Library.Utils;
|
|
||||||
using Serein.NodeFlow.Tool;
|
using Serein.NodeFlow.Tool;
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace Serein.NodeFlow.Model.Library
|
namespace Serein.NodeFlow.Model.Library
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
using Serein.Library;
|
using Serein.Library;
|
||||||
using Serein.Library.Api;
|
using Serein.Library.Api;
|
||||||
using Serein.Library.FlowNode;
|
|
||||||
using Serein.Library.Utils;
|
|
||||||
using Serein.NodeFlow.Model.Library;
|
using Serein.NodeFlow.Model.Library;
|
||||||
using Serein.NodeFlow.Tool;
|
using Serein.NodeFlow.Tool;
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Serein.NodeFlow.Services
|
namespace Serein.NodeFlow.Services
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
using Serein.Library.Api;
|
using Serein.Library;
|
||||||
using Serein.Library.Utils;
|
using Serein.Library.Api;
|
||||||
using Serein.Library;
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Reflection;
|
|
||||||
using Serein.Library.FlowNode;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Serein.NodeFlow.Tool;
|
namespace Serein.NodeFlow.Tool;
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,14 @@ namespace Serein.Library
|
|||||||
/// 是否禁止参数进行修改(初始化后不能再通过 Setter 修改)
|
/// 是否禁止参数进行修改(初始化后不能再通过 Setter 修改)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsProtection = false;
|
public bool IsProtection = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否需要验证参数
|
||||||
|
/// </summary>
|
||||||
|
public bool IsVerify = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义代码(属性变更前)
|
/// 自定义代码(属性变更前)
|
||||||
|
|||||||
@@ -146,9 +146,17 @@ namespace Serein.Library.NodeGenerator
|
|||||||
var attributeInfo = fieldKV.Value; // 缓存的特性信息
|
var attributeInfo = fieldKV.Value; // 缓存的特性信息
|
||||||
|
|
||||||
var isProtection = attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.IsProtection), value => bool.Parse(value)); // 是否为保护字段
|
var isProtection = attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.IsProtection), value => bool.Parse(value)); // 是否为保护字段
|
||||||
|
var isVerify = attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.IsVerify), value => bool.Parse(value)); // 是否为保护字段
|
||||||
|
|
||||||
//sb.AppendLine(leadingTrivia);
|
//sb.AppendLine(leadingTrivia);
|
||||||
sb.AppendLine($" partial void On{propertyName}Changed({fieldType} oldValue, {fieldType} newValue);");
|
sb.AppendLine($" partial void On{propertyName}Changed({fieldType} oldValue, {fieldType} newValue);");
|
||||||
sb.AppendLine($" partial void On{propertyName}Changed({fieldType} value);");
|
sb.AppendLine($" partial void On{propertyName}Changed({fieldType} value);");
|
||||||
|
|
||||||
|
if (isVerify)
|
||||||
|
{
|
||||||
|
sb.AppendLine($" partial void BeforeThe{propertyName}(ref bool __isAllow, {fieldType} newValue);");
|
||||||
|
}
|
||||||
|
|
||||||
if (isProtection)
|
if (isProtection)
|
||||||
{
|
{
|
||||||
sb.AppendLine($" private bool __{propertyName}ProtectionField = false;");
|
sb.AppendLine($" private bool __{propertyName}ProtectionField = false;");
|
||||||
@@ -164,7 +172,12 @@ namespace Serein.Library.NodeGenerator
|
|||||||
sb.AppendLine( " set");
|
sb.AppendLine( " set");
|
||||||
sb.AppendLine( " {");
|
sb.AppendLine( " {");
|
||||||
//sb.AppendLine($" if ({fieldName} {(isProtection ? "== default" : "!= value")})"); // 非保护的Setter
|
//sb.AppendLine($" if ({fieldName} {(isProtection ? "== default" : "!= value")})"); // 非保护的Setter
|
||||||
|
if (isVerify)
|
||||||
|
{
|
||||||
|
sb.AppendLine($" bool __isAllow = true;");
|
||||||
|
sb.AppendLine($" BeforeThe{propertyName}(ref __isAllow, value);");
|
||||||
|
sb.AppendLine($" if(!__isAllow) return; // 修改验证失败");
|
||||||
|
}
|
||||||
sb.AppendLine($" var __oldValue = {fieldName};");
|
sb.AppendLine($" var __oldValue = {fieldName};");
|
||||||
if (isProtection)
|
if (isProtection)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user