2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.Library.Enums;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Serein.Library.Attributes
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示该属性为自动注入依赖项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
|
|
|
|
public sealed class AutoInjectionAttribute : Attribute
|
|
|
|
|
|
{
|
2024-09-30 02:45:49 +08:00
|
|
|
|
}
|
2024-09-28 23:55:19 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-30 02:45:49 +08:00
|
|
|
|
/// 表示该类自动注册(单例模式)
|
2024-09-28 23:55:19 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
|
public sealed class AutoRegisterAttribute : Attribute
|
|
|
|
|
|
{
|
2024-09-12 20:32:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-30 02:45:49 +08:00
|
|
|
|
/// 用来判断一个类是否需要注册并构建节点
|
2024-09-12 20:32:54 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
|
public class DynamicFlowAttribute : Attribute
|
|
|
|
|
|
{
|
2024-10-07 15:15:18 +08:00
|
|
|
|
public DynamicFlowAttribute(string name = "",bool scan = true)
|
2024-09-12 20:32:54 +08:00
|
|
|
|
{
|
2024-10-07 15:15:18 +08:00
|
|
|
|
Name = name;
|
2024-09-12 20:32:54 +08:00
|
|
|
|
Scan = scan;
|
|
|
|
|
|
}
|
2024-10-07 15:15:18 +08:00
|
|
|
|
public string Name { get; set; }
|
2024-09-12 20:32:54 +08:00
|
|
|
|
public bool Scan { get; set; } = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-09-12 20:32:54 +08:00
|
|
|
|
/// <summary>
|
2024-09-15 22:07:10 +08:00
|
|
|
|
/// 建议触发器手动设置返回类型
|
2024-09-12 20:32:54 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
|
|
|
|
|
public class NodeActionAttribute : Attribute
|
|
|
|
|
|
{
|
|
|
|
|
|
public NodeActionAttribute(NodeType methodDynamicType,
|
|
|
|
|
|
string methodTips = "",
|
|
|
|
|
|
bool scan = true,
|
|
|
|
|
|
string lockName = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
Scan = scan;
|
|
|
|
|
|
MethodDynamicType = methodDynamicType;
|
|
|
|
|
|
MethodTips = methodTips;
|
|
|
|
|
|
LockName = lockName;
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public bool Scan;
|
|
|
|
|
|
public string MethodTips;
|
|
|
|
|
|
public NodeType MethodDynamicType;
|
|
|
|
|
|
public Type ReturnType;
|
|
|
|
|
|
public string LockName;
|
2024-09-12 20:32:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-25 22:20:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//[AttributeUsage(AttributeTargets.Field)]
|
|
|
|
|
|
//public class BindTypeAttribute : Attribute
|
|
|
|
|
|
//{
|
|
|
|
|
|
// public Type Type { get; }
|
|
|
|
|
|
|
|
|
|
|
|
// public BindTypeAttribute(Type type)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Type = type;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
2024-10-07 15:15:18 +08:00
|
|
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
2024-09-25 22:20:23 +08:00
|
|
|
|
public class BindValueAttribute : Attribute
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Value { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public BindValueAttribute(object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
Value = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-27 10:30:19 +08:00
|
|
|
|
/// <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("需要枚举类型");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-28 23:55:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 绑定转换器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Parameter)]
|
|
|
|
|
|
public class BindConvertorAttribute : Attribute
|
2024-09-25 22:20:23 +08:00
|
|
|
|
{
|
2024-09-28 23:55:19 +08:00
|
|
|
|
public Type EnumType { get; }
|
|
|
|
|
|
public Type ConvertorType { get; }
|
2024-09-25 22:20:23 +08:00
|
|
|
|
|
2024-09-28 23:55:19 +08:00
|
|
|
|
public BindConvertorAttribute(Type @enum, Type convertor)
|
2024-09-25 22:20:23 +08:00
|
|
|
|
{
|
2024-09-28 23:55:19 +08:00
|
|
|
|
this.EnumType = @enum;
|
|
|
|
|
|
this.ConvertorType = convertor;
|
2024-09-25 22:20:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-28 23:55:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 枚举转换器接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TEnum"></typeparam>
|
|
|
|
|
|
/// <typeparam name="TValue"></typeparam>
|
|
|
|
|
|
public interface IEnumConvertor<TEnum, TValue>
|
|
|
|
|
|
{
|
|
|
|
|
|
TValue Convertor(TEnum e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-12 20:32:54 +08:00
|
|
|
|
}
|