/// <summary> /// Locates and returns the type in the set of known assemblies /// that is equivalent to the given type. /// </summary> /// <param name="typeFullName">FullName of the type to search for</param> private Type FindSharedTypeInAssemblies(string typeFullName) { foreach (Assembly assembly in this.Assemblies) { // Utility autorecovers and logs known common exceptions IEnumerable <Type> types = AssemblyUtilities.GetExportedTypes(assembly, this._logger); foreach (Type searchType in types) { if (string.Equals(typeFullName, searchType.FullName, StringComparison.Ordinal)) { return(searchType); } } } return(null); }
/// <summary> /// Locates and returns the type in the set of known assemblies /// that is equivalent to the given type. /// </summary> /// <param name="type">The type to use for comparison</param> /// <returns>The equivalent type from the known assemblies, or null if not found</returns> private Type FindSharedType(Type type) { foreach (var assembly in Assemblies) { // Utility autorecovers and logs known common exceptions IEnumerable <Type> types = AssemblyUtilities.GetExportedTypes(assembly, _logger); foreach (Type searchType in types) { if (IsSameType(type, searchType)) { return(searchType); } } } // TODO: review // If we could not find the type, but it lives in mscorlib, // we treat it specially because we cannot load mscorlib to tell. return(EquivalentMsCorlibType(type)); }
/// <summary> /// Searches the shared assemblies for a type of the given name. /// </summary> /// <param name="typeName">The fully-qualified type name.</param> /// <returns>The <see cref="Type"/> or <c>null</c> if it is not in one of the shared assemblies.</returns> private Type FindSharedType(string typeName) { var type = Type.GetType(typeName, /*throwOnError*/ false); if (type != null) { return(FindSharedType(type)); } foreach (var assembly in Assemblies) { // Utility autorecovers and logs known common exceptions IEnumerable <Type> types = AssemblyUtilities.GetExportedTypes(assembly, this._logger); foreach (Type searchType in types) { if (string.Equals(typeName, searchType.FullName, StringComparison.OrdinalIgnoreCase)) { return(searchType); } } } return(null); }