DragonECS/src/Internal/ReflectionUtility.cs

23 lines
740 B
C#
Raw Normal View History

2024-03-06 21:35:34 +08:00
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS.Internal
{
internal static class ReflectionUtility
{
[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;
}
}
}