private ConcurrentDictionary <string, IList <string> > LoadClrToXmlNs() { ConcurrentDictionary <string, IList <string> > dict = XamlSchemaContext.CreateDictionary <string, IList <string> >(); System.Reflection.Assembly assembly = this.Assembly; if (assembly != null) { foreach (XmlNsDefinition definition in this.NsDefs) { IList <string> list; if (!dict.TryGetValue(definition.ClrNamespace, out list)) { list = new List <string>(); dict.TryAdd(definition.ClrNamespace, list); } list.Add(definition.XmlNamespace); } string assemblyName = this._fullyQualifyAssemblyName ? assembly.FullName : XamlSchemaContext.GetAssemblyShortName(assembly); foreach (KeyValuePair <string, IList <string> > pair in dict) { List <string> list2 = (List <string>)pair.Value; NamespaceComparer comparer = new NamespaceComparer(this, assembly); list2.Sort(new Comparison <string>(comparer.CompareNamespacesByPreference)); string uri = ClrNamespaceUriParser.GetUri(pair.Key, assemblyName); list2.Add(uri); } this.MakeListsImmutable(dict); } return(dict); }
private ReadOnlyCollection <string> GetXmlNsMappings(Assembly assembly, string clrNs) { IList <string> list; ConcurrentDictionary <string, IList <string> > clrToXmlNs = this.GetXmlNsInfo(assembly).ClrToXmlNs; clrNs = clrNs ?? string.Empty; if (!clrToXmlNs.TryGetValue(clrNs, out list)) { string assemblyName = this.FullyQualifyAssemblyNamesInClrNamespaces ? assembly.FullName : GetAssemblyShortName(assembly); string uri = ClrNamespaceUriParser.GetUri(clrNs, assemblyName); list = new List <string> { uri }.AsReadOnly(); TryAdd <string, IList <string> >(clrToXmlNs, clrNs, list); } return((ReadOnlyCollection <string>)list); }
internal bool IsXmlNamespaceSupported(string xmlNamespace, out string newXmlNamespace) { string str; string fullName; if (((this._mergedSettings.LocalAssembly != null) && ClrNamespaceUriParser.TryParseUri(xmlNamespace, out str, out fullName)) && string.IsNullOrEmpty(fullName)) { fullName = this._mergedSettings.LocalAssembly.FullName; newXmlNamespace = ClrNamespaceUriParser.GetUri(str, fullName); return(true); } bool flag = this._context.SchemaContext.TryGetCompatibleXamlNamespace(xmlNamespace, out newXmlNamespace); if (newXmlNamespace == null) { newXmlNamespace = string.Empty; } return(flag); }
// Return true if the passed namespace is known, meaning that it maps // to a set of assemblies and clr namespaces internal bool IsXmlNamespaceSupported(string xmlNamespace, out string newXmlNamespace) { // 4 cases: refer to Framework\XamlParser.IsXmlNamespaceSupported // startins with clr-namespace: // Namespace is known // http://schemas.microsoft.com/winfx/2006/xaml/presentation/options // We're inside of a XmlDataIsland // First, substitute in the LocalAssembly if needed if (_mergedSettings.LocalAssembly != null) { string clrNs, assemblyName; if (ClrNamespaceUriParser.TryParseUri(xmlNamespace, out clrNs, out assemblyName) && String.IsNullOrEmpty(assemblyName)) { assemblyName = _mergedSettings.LocalAssembly.FullName; newXmlNamespace = ClrNamespaceUriParser.GetUri(clrNs, assemblyName); return(true); } } bool result = _context.SchemaContext.TryGetCompatibleXamlNamespace(xmlNamespace, out newXmlNamespace); if (newXmlNamespace == null) { newXmlNamespace = string.Empty; } // we need to treat all namespaces inside of XmlDataIslands as Supported. // we need to tree Freeze as known, if it is around... don't hardcode. //else if (xmlNamespace == XamlReaderHelper.PresentationOptionsNamespaceURI) //{ // // PresentationOptions is expected to be marked as 'ignorable' in most Xaml // // so that other Xaml parsers don't have to interpret it, but this parser // // does handle it to support it's Freeze attribute. // return true; //} return(result); }
ConcurrentDictionary <string, IList <string> > LoadClrToXmlNs() { ConcurrentDictionary <string, IList <string> > result = XamlSchemaContext.CreateDictionary <string, IList <string> >(); Assembly assembly = Assembly; if (assembly == null) { return(result); } foreach (XmlNsDefinition nsDef in NsDefs) { IList <string> xmlNamespaceList; if (!result.TryGetValue(nsDef.ClrNamespace, out xmlNamespaceList)) { xmlNamespaceList = new List <string>(); result.TryAdd(nsDef.ClrNamespace, xmlNamespaceList); } xmlNamespaceList.Add(nsDef.XmlNamespace); } string assemblyName = _fullyQualifyAssemblyName ? assembly.FullName : XamlSchemaContext.GetAssemblyShortName(assembly); foreach (KeyValuePair <string, IList <string> > clrToXmlNs in result) { // Sort namespaces in preference order List <string> nsList = (List <string>)clrToXmlNs.Value; NamespaceComparer comparer = new NamespaceComparer(this, assembly); nsList.Sort(comparer.CompareNamespacesByPreference); // Add clr-namespace form as last choice string clrNsUri = ClrNamespaceUriParser.GetUri(clrToXmlNs.Key, assemblyName); nsList.Add(clrNsUri); } // Convert to read-only lists so we can safely return these from public API MakeListsImmutable(result); return(result); }