/// <summary> /// Gets the name of the type referenced by the ID /// </summary> /// <remarks> /// This has a linear lookup. Should only be used for error reporting or optimized if used in actual execution /// </remarks> public static string GetTypeName(int typeId) { foreach (Type type in Types) { if (HashCodeHelper.GetOrdinalHashCode(type.FullName) == typeId) { return(type.FullName); } } return("Unknown"); }
/// <summary> /// Gets a unique identifier for a type /// </summary> public static int GetTypeId(Type type) { Contract.RequiresNotNull(type); return(s_types.GetOrAdd(type, static t => HashCodeHelper.GetOrdinalHashCode(t.FullName))); }
/// <summary> /// Gets a unique identifier for a type /// </summary> public static int GetTypeId(Type type) { Contract.Requires(type != null); return(s_types.GetOrAdd(type, _ => HashCodeHelper.GetOrdinalHashCode(type.FullName))); }