public void setupRenamedSaveableTypes(RenamedTypeMap renamedTypeMap) { }
/// <summary> /// Search for a given type using an assemblyQualifiedName. First this /// will use the standard Type.GetType function. If that fails it will /// search all the plugin loaded assemblies for the type directly. If /// that fails the function will return null. If sucessful the matching /// type will be returned. /// </summary> /// <remarks> /// This function could be optimized. For now it will search all loaded /// assemblies in a loop when the Type.GetType function call fails. /// </remarks> /// <param name="assemblyQualifiedName">The AssemblyQualifiedName to search for.</param> /// <returns>The matching type or null if the type cannot be found.</returns> internal Type findType(String assemblyQualifiedName) { Type type; if (!typeCache.TryGetValue(assemblyQualifiedName, out type)) { type = Type.GetType(assemblyQualifiedName, false); //If that fails do the slow search. if (type == null) { String typeName = DefaultTypeFinder.GetTypeNameWithoutAssembly(assemblyQualifiedName); //If there is not yet a renamed type map, create it. if (renamedTypeMap == null) { renamedTypeMap = new RenamedTypeMap(); foreach (var plugin in loadedPlugins) { plugin.setupRenamedSaveableTypes(renamedTypeMap); } } //Check the rename cache if (!renamedTypeMap.tryGetType(typeName, out type)) { Log.Warning("TypeSearch: Had to do slow search looking for type \'{0}\'. You should fix the source file searching for this type or add an entry to the renamed type maps for '{1}'", assemblyQualifiedName, typeName); foreach (Assembly assembly in pluginAssemblies) { type = assembly.GetType(typeName); if (type != null) { break; } } //If that fails search all loaded assemblies. if (type == null) { foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { type = assembly.GetType(typeName); if (type != null) { break; } } } } //If we found something put it in the slow search cache so it can be found quicker later if (type != null) { Log.Warning("TypeSearch: Replacement found for type \'{0}\'. Replacement type is \'{1}\'", assemblyQualifiedName, type.AssemblyQualifiedName); } else { Log.Warning("TypeSearch: Unable to find replacement for type \'{0}\'.", assemblyQualifiedName); } } typeCache.Add(assemblyQualifiedName, type); } return(type); }