static TypeLoader() { // we use Int32 here because we get all the information about Mono's mscorlib and just have to change the class name cachedMonoRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); cachedMonoRuntimeType = new TypeName(cachedMonoRuntimeType, "MonoType"); cachedWindowsRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); cachedWindowsRuntimeType = new TypeName(cachedWindowsRuntimeType, "RuntimeType"); // we need the information about the Persistence assembly, so we use TypeName here because it is contained in this assembly cachedMonoObjectEqualityComparerType = TypeNameParser.Parse(typeof(TypeName).AssemblyQualifiedName); cachedMonoObjectEqualityComparerType = new TypeName(cachedMonoObjectEqualityComparerType, "ObjectEqualityComparer", "HeuristicLab.Persistence.Mono"); cachedWindowsObjectEqualityComparerType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); cachedWindowsObjectEqualityComparerType = new TypeName(cachedWindowsObjectEqualityComparerType, "ObjectEqualityComparer", "System.Collections.Generic"); }
public static Type Load(string typeNameString) { TypeName typeName = null; try { typeName = TypeNameParser.Parse(typeNameString); } catch (Exception) { throw new PersistenceException(String.Format( "Could not parse type string \"{0}\"", typeNameString)); } try { // try to load type normally return(LoadInternal(typeName)); } catch (PersistenceException) { #region Mono Compatibility // if that fails, try to convert to the corresponding Mono or .NET type if (MonoInstalled) { typeName = GetMonoType(typeName); Logger.Info(String.Format(@"Trying to load Mono type ""{0}"" instead of .NET type ""{1}""", typeName, typeNameString)); } else { typeName = GetDotNetType(typeName); Logger.Info(String.Format(@"Trying to load .NET type ""{0}"" instead of Mono type ""{1}""", typeName, typeNameString)); } return(LoadInternal(typeName)); #endregion } }
/// <summary> /// Get an assembly qualified name withough version information. /// </summary> /// <param name="type">The type.</param> /// <returns>A full type name without version information.</returns> public static string VersionInvariantName(this Type type) { return(TypeNameParser.Parse(type.AssemblyQualifiedName).ToString(false)); }