BITKit/Src/Core/Attributes/IBITCommand.cs

72 lines
2.1 KiB
C#
Raw Normal View History

2023-06-05 19:57:17 +08:00
using System;
namespace BITKit
{
[AttributeUsage(AttributeTargets.Method)]
public class BITCommandAttribute : Attribute { }
2023-10-24 23:38:22 +08:00
/// <summary>
/// 自动注入依赖
/// </summary>
2023-06-05 19:57:17 +08:00
[AttributeUsage(AttributeTargets.Field)]
public class InjectAttribute : System.Attribute
{
2024-03-31 23:31:00 +08:00
public static void Clear(object obj)
{
var fields = obj.GetType().GetFields(ReflectionHelper.Flags);
foreach (var field in fields)
{
if (field.GetCustomAttributes(typeof(InjectAttribute), true).Length > 0)
{
field.SetValue(obj, null);
}
}
}
2023-10-24 23:38:22 +08:00
public readonly bool CanBeNull;
public InjectAttribute()
{
}
public InjectAttribute(bool canBeNull)
{
CanBeNull = canBeNull;
}
2023-06-05 19:57:17 +08:00
}
2023-10-24 23:38:22 +08:00
2024-03-31 23:31:00 +08:00
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
2023-10-06 23:43:19 +08:00
public class CustomTypeAttribute : System.Attribute
{
public readonly Type Type;
2024-03-31 23:31:00 +08:00
public readonly bool AsGlobal;
2023-10-06 23:43:19 +08:00
public CustomTypeAttribute(Type type)
{
Type = type;
}
2024-03-31 23:31:00 +08:00
public CustomTypeAttribute(Type type, bool asGlobal)
{
Type = type;
AsGlobal = asGlobal;
}
public CustomTypeAttribute(bool asGlobal)
{
AsGlobal = asGlobal;
}
2023-10-06 23:43:19 +08:00
}
2023-10-24 23:38:22 +08:00
#if UNITY_64
2024-03-31 23:31:00 +08:00
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
2023-10-24 23:38:22 +08:00
public class ExportAttribute : System.Attribute
{
2024-03-31 23:31:00 +08:00
public readonly string Name;
public readonly IExportSetting Settings;
public ExportAttribute(){}
public ExportAttribute(IExportSetting settings)
{
Settings = settings;
}
public ExportAttribute(string name)
{
Name = name;
}
2023-10-24 23:38:22 +08:00
}
2024-03-31 23:31:00 +08:00
public interface IExportSetting{}
2023-10-24 23:38:22 +08:00
#endif
2023-06-05 19:57:17 +08:00
}