DragonECS-Unity/src/Internal/ReflectionExtensions.cs
2024-09-29 15:59:14 +08:00

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