2024-03-07 03:18:00 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
2024-09-29 15:59:14 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2024-03-07 03:18:00 +08:00
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS.Unity.Internal
|
|
|
|
|
{
|
|
|
|
|
internal static class ReflectionExtensions
|
|
|
|
|
{
|
2024-09-29 15:59:14 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-03-07 03:18:00 +08:00
|
|
|
|
public static bool TryGetAttribute<T>(this MemberInfo self, out T attrbiute) where T : Attribute
|
|
|
|
|
{
|
|
|
|
|
attrbiute = self.GetCustomAttribute<T>();
|
|
|
|
|
return attrbiute != null;
|
|
|
|
|
}
|
2024-09-29 15:59:14 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-03-07 03:18:00 +08:00
|
|
|
|
public static bool HasAttribute<T>(this MemberInfo self) where T : Attribute
|
|
|
|
|
{
|
|
|
|
|
return self.GetCustomAttribute<T>() != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|