DragonECS-Unity/src/Internal/ReflectionExtensions.cs

21 lines
555 B
C#
Raw Normal View History

2024-03-07 03:18:00 +08:00
#if UNITY_EDITOR
using System;
using System.Reflection;
namespace DCFApixels.DragonECS.Unity.Internal
{
internal static class ReflectionExtensions
{
public static bool TryGetAttribute<T>(this MemberInfo self, out T attrbiute) where T : Attribute
{
attrbiute = self.GetCustomAttribute<T>();
return attrbiute != null;
}
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
{
return self.GetCustomAttribute<T>() != null;
}
}
}
#endif