using System.Runtime.CompilerServices; namespace Ghost.Entities.Utilities; internal static class TypeHandle { /// /// Gets the type handle for the specified type. /// /// The type to get the handle for. /// The type handle as a nint. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static nint Get() { return typeof(T).TypeHandle.Value; } /// /// Gets the type handle for the specified type. /// /// The type to get the handle for. /// The type handle as a nint. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static nint Get(Type type) { return type.TypeHandle.Value; } public static Type? ToType(nint handle) { return Type.GetTypeFromHandle(RuntimeTypeHandle.FromIntPtr(handle)); } }