2025-03-14 16:53:33 +08:00
|
|
|
|
#if DISABLE_DEBUG
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
using System;
|
2024-02-25 17:36:33 +08:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS.AutoInjections.Internal
|
|
|
|
|
{
|
|
|
|
|
internal static class ReflectionExtenions
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public static bool TryGetCustomAttribute<T>(this Type self, out T attribute) where T : Attribute
|
|
|
|
|
{
|
|
|
|
|
attribute = self.GetCustomAttribute<T>();
|
|
|
|
|
return attribute != null;
|
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public static bool TryGetCustomAttribute<T>(this MemberInfo self, out T attribute) where T : Attribute
|
|
|
|
|
{
|
|
|
|
|
attribute = self.GetCustomAttribute<T>();
|
|
|
|
|
return attribute != null;
|
|
|
|
|
}
|
2025-03-10 22:21:27 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
|
|
|
|
|
{
|
|
|
|
|
return self.GetCustomAttribute<T>() != null;
|
|
|
|
|
}
|
2024-02-25 17:36:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|