mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-18 13:24:35 +08:00
31 lines
1016 B
C#
31 lines
1016 B
C#
#if DISABLE_DEBUG
|
|
#undef DEBUG
|
|
#endif
|
|
using System;
|
|
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;
|
|
}
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
|
|
{
|
|
return self.GetCustomAttribute<T>() != null;
|
|
}
|
|
}
|
|
}
|