using System; namespace BITKit { [AttributeUsage(AttributeTargets.Method)] public class BITCommandAttribute : Attribute { } /// /// 自动注入依赖 /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] public class InjectAttribute : Attribute { 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); } } } public readonly bool CanBeNull; public InjectAttribute() { } public InjectAttribute(bool canBeNull) { CanBeNull = canBeNull; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)] public class CustomTypeAttribute : System.Attribute { public readonly Type Type; public readonly bool AsGlobal; public CustomTypeAttribute(Type type) { Type = type; } public CustomTypeAttribute(Type type, bool asGlobal) { Type = type; AsGlobal = asGlobal; } public CustomTypeAttribute(bool asGlobal) { AsGlobal = asGlobal; } } #if UNITY_64 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class ExportAttribute : System.Attribute { public readonly string Name; public readonly IExportSetting Settings; public ExportAttribute(){} public ExportAttribute(IExportSetting settings) { Settings = settings; } public ExportAttribute(string name) { Name = name; } } public interface IExportSetting{} #endif }