private bool UpdateXmlNsInfo(XmlNsInfo nsInfo) { bool flag = this.UpdateNamespaceByUriList(nsInfo); if (this._preferredPrefixes != null) { this.UpdatePreferredPrefixes(nsInfo, this._preferredPrefixes); } return(flag); }
private bool UpdateNamespaceByUriList(XmlNsInfo nsInfo) { bool flag = false; foreach (XmlNsInfo.XmlNsDefinition definition in nsInfo.NsDefs) { AssemblyNamespacePair pair = new AssemblyNamespacePair(nsInfo.Assembly, definition.ClrNamespace); this.GetXamlNamespace(definition.XmlNamespace).AddAssemblyNamespacePair(pair); flag = true; } return(flag); }
private void UpdateXmlNsInfo() { bool flag = false; lock (this._syncExaminingAssemblies) { IList <Assembly> list; lock (this._syncAccessingUnexaminedAssemblies) { list = this._unexaminedAssemblies; this._unexaminedAssemblies = new WeakReferenceList <Assembly>(0); } bool flag2 = this.ReferenceAssemblies != null; for (int i = 0; i < list.Count; i++) { Assembly assembly = list[i]; if (assembly != null) { XmlNsInfo xmlNsInfo = this.GetXmlNsInfo(assembly); try { if (this.UpdateXmlNsInfo(xmlNsInfo)) { flag = true; } } catch (Exception exception) { if (flag2 || CriticalExceptions.IsCriticalException(exception)) { lock (this._syncAccessingUnexaminedAssemblies) { for (int j = i; j < list.Count; j++) { this._unexaminedAssemblies.Add(list[j]); } } throw; } } } } if (flag && (this._nonClrNamespaces != null)) { this._nonClrNamespaces = null; } } }
private void UpdatePreferredPrefixes(XmlNsInfo newNamespaces, ConcurrentDictionary <string, string> prefixDict) { foreach (KeyValuePair <string, string> pair in newNamespaces.Prefixes) { string str; string preferredPrefix = pair.Value; if (!prefixDict.TryGetValue(pair.Key, out str)) { str = TryAdd <string, string>(prefixDict, pair.Key, preferredPrefix); } while (str != preferredPrefix) { preferredPrefix = XmlNsInfo.GetPreferredPrefix(str, preferredPrefix); if (!KS.Eq(preferredPrefix, str)) { str = TryUpdate <string, string>(prefixDict, pair.Key, preferredPrefix, str); } } } }
private XmlNsInfo GetXmlNsInfo(Assembly assembly) { XmlNsInfo info; if ((this.XmlnsInfo.TryGetValue(assembly, out info) || (((this._xmlnsInfoForDynamicAssemblies != null) && assembly.IsDynamic) && this._xmlnsInfoForDynamicAssemblies.TryGetValue(new WeakRefKey(assembly), out info))) || ((this._xmlnsInfoForUnreferencedAssemblies != null) && this._xmlnsInfoForUnreferencedAssemblies.TryGetValue(assembly, out info))) { return(info); } bool flag = false; if (this._referenceAssemblies != null) { foreach (Assembly assembly2 in this._referenceAssemblies) { if (object.ReferenceEquals(assembly2, assembly)) { flag = true; break; } } } else { flag = !assembly.ReflectionOnly && typeof(object).Assembly.GetType().IsAssignableFrom(assembly.GetType()); } info = new XmlNsInfo(assembly, this.FullyQualifyAssemblyNamesInClrNamespaces); if (flag) { if (assembly.IsDynamic && (this._referenceAssemblies == null)) { info = TryAdd <WeakRefKey, XmlNsInfo>(this.XmlnsInfoForDynamicAssemblies, new WeakRefKey(assembly), info); this.RegisterAssemblyCleanup(); return(info); } return(TryAdd <Assembly, XmlNsInfo>(this.XmlnsInfo, assembly, info)); } return(TryAdd <Assembly, XmlNsInfo>(this.XmlnsInfoForUnreferencedAssemblies, assembly, info)); }