Type ResolveDataContractTypeInSharedTypeMode(string assemblyName, string typeName, out Assembly assembly) { assembly = null; Type type = null; if (binder != null) { type = binder.BindToType(assemblyName, typeName); } if (type == null) { XmlObjectDataContractTypeKey key = new XmlObjectDataContractTypeKey(assemblyName, typeName); XmlObjectDataContractTypeInfo dataContractTypeInfo = (XmlObjectDataContractTypeInfo)dataContractTypeCache[key]; if (dataContractTypeInfo == null) { if (assemblyFormat == FormatterAssemblyStyle.Full) { if (assemblyName == Globals.MscorlibAssemblyName) { assembly = Globals.TypeOfInt.Assembly; } else { assembly = Assembly.Load(assemblyName); } if (assembly != null) { type = assembly.GetType(typeName); } } else { assembly = XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName(assemblyName); if (assembly != null) { // Catching any exceptions that could be thrown from a failure on assembly load // This is necessary, for example, if there are generic parameters that are qualified with a version of the assembly that predates the one available try { type = assembly.GetType(typeName); } catch (TypeLoadException) { } catch (FileNotFoundException) { } catch (FileLoadException) { } catch (BadImageFormatException) { } if (type == null) { type = Type.GetType(typeName, XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName, new TopLevelAssemblyTypeResolver(assembly).ResolveType, false /* throwOnError */); } } } if (type != null) { CheckTypeForwardedTo(assembly, type.Assembly, type); dataContractTypeInfo = new XmlObjectDataContractTypeInfo(assembly, type); lock (dataContractTypeCache) { if (!dataContractTypeCache.ContainsKey(key)) { dataContractTypeCache[key] = dataContractTypeInfo; } } } } else { assembly = dataContractTypeInfo.Assembly; type = dataContractTypeInfo.Type; } } return(type); }
private Type ResolveDataContractTypeInSharedTypeMode(string assemblyName, string typeName, out Assembly assembly) { assembly = null; Type type = null; if (this.binder != null) { type = this.binder.BindToType(assemblyName, typeName); } if (type != null) { return type; } XmlObjectDataContractTypeKey key = new XmlObjectDataContractTypeKey(assemblyName, typeName); XmlObjectDataContractTypeInfo info = (XmlObjectDataContractTypeInfo) dataContractTypeCache[key]; if (info == null) { if (this.assemblyFormat == FormatterAssemblyStyle.Full) { if (assemblyName == "0") { assembly = Globals.TypeOfInt.Assembly; } else { assembly = Assembly.Load(assemblyName); } if (assembly != null) { type = assembly.GetType(typeName); } } else { assembly = ResolveSimpleAssemblyName(assemblyName); if (assembly != null) { try { type = assembly.GetType(typeName); } catch (TypeLoadException) { } catch (FileNotFoundException) { } catch (FileLoadException) { } catch (BadImageFormatException) { } if (type == null) { type = Type.GetType(typeName, new Func<AssemblyName, Assembly>(XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName), new Func<Assembly, string, bool, Type>(new TopLevelAssemblyTypeResolver(assembly).ResolveType), false); } } } if (type == null) { return type; } info = new XmlObjectDataContractTypeInfo(assembly, type); lock (dataContractTypeCache) { if (!dataContractTypeCache.ContainsKey(key)) { dataContractTypeCache[key] = info; } return type; } } assembly = info.Assembly; return info.Type; }
Type ResolveDataContractTypeInSharedTypeMode(string assemblyName, string typeName, out Assembly assembly) { assembly = null; Type type = null; if (binder != null) type = binder.BindToType(assemblyName, typeName); if (type == null) { XmlObjectDataContractTypeKey key = new XmlObjectDataContractTypeKey(assemblyName, typeName); XmlObjectDataContractTypeInfo dataContractTypeInfo = (XmlObjectDataContractTypeInfo)dataContractTypeCache[key]; if (dataContractTypeInfo == null) { if (assemblyFormat == FormatterAssemblyStyle.Full) { if (assemblyName == Globals.MscorlibAssemblyName) { assembly = Globals.TypeOfInt.Assembly; } else { assembly = Assembly.Load(assemblyName); } if (assembly != null) type = assembly.GetType(typeName); } else { assembly = XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName(assemblyName); if (assembly != null) { // Catching any exceptions that could be thrown from a failure on assembly load // This is necessary, for example, if there are generic parameters that are qualified with a version of the assembly that predates the one available try { type = assembly.GetType(typeName); } catch (TypeLoadException) { } catch (FileNotFoundException) { } catch (FileLoadException) { } catch (BadImageFormatException) { } if (type == null) { type = Type.GetType(typeName, XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName, new TopLevelAssemblyTypeResolver(assembly).ResolveType, false /* throwOnError */); } } } if (type != null) { CheckTypeForwardedTo(assembly, type.Assembly, type); dataContractTypeInfo = new XmlObjectDataContractTypeInfo(assembly, type); lock (dataContractTypeCache) { if (!dataContractTypeCache.ContainsKey(key)) { dataContractTypeCache[key] = dataContractTypeInfo; } } } } else { assembly = dataContractTypeInfo.Assembly; type = dataContractTypeInfo.Type; } } return type; }
private Type ResolveDataContractTypeInSharedTypeMode(string assemblyName, string typeName, out Assembly assembly) { assembly = null; Type type = null; if (this.binder != null) { type = this.binder.BindToType(assemblyName, typeName); } if (type != null) { return(type); } XmlObjectDataContractTypeKey key = new XmlObjectDataContractTypeKey(assemblyName, typeName); XmlObjectDataContractTypeInfo info = (XmlObjectDataContractTypeInfo)dataContractTypeCache[key]; if (info == null) { if (this.assemblyFormat == FormatterAssemblyStyle.Full) { if (assemblyName == "0") { assembly = Globals.TypeOfInt.Assembly; } else { assembly = Assembly.Load(assemblyName); } if (assembly != null) { type = assembly.GetType(typeName); } } else { assembly = ResolveSimpleAssemblyName(assemblyName); if (assembly != null) { try { type = assembly.GetType(typeName); } catch (TypeLoadException) { } catch (FileNotFoundException) { } catch (FileLoadException) { } catch (BadImageFormatException) { } if (type == null) { type = Type.GetType(typeName, new Func <AssemblyName, Assembly>(XmlObjectSerializerReadContextComplex.ResolveSimpleAssemblyName), new Func <Assembly, string, bool, Type>(new TopLevelAssemblyTypeResolver(assembly).ResolveType), false); } } } if (type == null) { return(type); } info = new XmlObjectDataContractTypeInfo(assembly, type); lock (dataContractTypeCache) { if (!dataContractTypeCache.ContainsKey(key)) { dataContractTypeCache[key] = info; } return(type); } } assembly = info.Assembly; return(info.Type); }