mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
24 lines
712 B
C#
24 lines
712 B
C#
#if UNITY_EDITOR
|
|
using System;
|
|
using System.Reflection;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace DCFApixels.DragonECS.Unity.Internal
|
|
{
|
|
internal static class ReflectionExtensions
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool TryGetAttribute<T>(this MemberInfo self, out T attrbiute) where T : Attribute
|
|
{
|
|
attrbiute = self.GetCustomAttribute<T>();
|
|
return attrbiute != null;
|
|
}
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
|
|
{
|
|
return self.GetCustomAttribute<T>() != null;
|
|
}
|
|
}
|
|
}
|
|
#endif
|