#if DISABLE_DEBUG #undef DEBUG #endif using System; using System.Reflection; using System.Runtime.CompilerServices; namespace DCFApixels.DragonECS.Core.Internal { internal static class ReflectionUtility { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Type GetPureType(this Type type) { if (type.IsGenericType) { return type.GetGenericTypeDefinition(); } return type; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryGetAttribute(this MemberInfo self, out T attribute) where T : Attribute { attribute = self.GetCustomAttribute(); return attribute != null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryGetAttribute(this MemberInfo self, bool inherit, out T attribute) where T : Attribute { attribute = self.GetCustomAttribute(inherit); return attribute != null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasAttribute(this MemberInfo self) where T : Attribute { return self.GetCustomAttribute() != null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasAttribute(this MemberInfo self, bool inherit) where T : Attribute { return self.GetCustomAttribute(inherit) != null; } public static bool IsCanInstantiated(this Type type) { return !type.IsAbstract && !type.IsInterface; } } }