DragonECS-AutoInjections/src/Attributes/InjectionAttributes.cs
2025-03-14 16:53:33 +08:00

38 lines
1.2 KiB
C#

#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public class DIAttribute : Attribute
{
public static readonly DIAttribute Dummy = new DIAttribute();
public readonly Type NotNullDummyType = null;
public readonly string NamedInjection = string.Empty;
public DIAttribute() { }
public DIAttribute(string namedInjection)
{
NamedInjection = namedInjection;
}
public DIAttribute(Type notNullDummyType)
{
NotNullDummyType = notNullDummyType;
}
public DIAttribute(string namedInjection, Type notNullDummyType)
{
NamedInjection = namedInjection;
NotNullDummyType = notNullDummyType;
}
}
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
[Obsolete("Use DI attribute")]
public sealed class EcsInjectAttribute : DIAttribute
{
public EcsInjectAttribute(Type notNullDummyType = null) : base(notNullDummyType) { }
}
}