/// <summary> /// Check an Xml namespace URI and loads the associated Clr namespaces and assemblies /// into ClrNamespaceAssemblyPair structures. /// Throws an exception if no valid namespaces are found. /// </summary> /// <param name="namespaceUri">Xml namespace that maps to one or more Clr namespace /// and assembly pairs</param> /// <returns>array of ClrNamespaceAssemblyPair structures</returns> internal static List<ClrNamespaceAssemblyPair> GetClrNamespacePairFromCache( string namespaceUri) { List<ClrNamespaceAssemblyPair> mappingArray = null; // if (_xmlnsCache == null) { #if PBTCOMPILER Debug.Assert(false, "Should initialize cache prior to compiling"); #else _xmlnsCache = new XmlnsCache(); #endif } mappingArray = _xmlnsCache.GetMappingArray(namespaceUri); return mappingArray; }
// // Pass xmlNamespace to AssemblyList mapping to xmlnsCache so that the xmlnsCache // can take the assembly list to get the right xmlns->clrns mapping later. // internal void SetUriToAssemblyNameMapping(string xmlNamespace, short[] assemblyIds) { // // If the xmlNamespace is for a mapping, there is no need to ask for xmlnsCache // to get xmlns->clrns mapping. // if (xmlNamespace.StartsWith(XamlReaderHelper.MappingProtocol, StringComparison.Ordinal)) { return; } if (_xmlnsCache == null) { _xmlnsCache = new XmlnsCache(); } string[] asmNameList = null; if (assemblyIds != null && assemblyIds.Length > 0) { asmNameList = new string[assemblyIds.Length]; for (int i = 0; i < assemblyIds.Length; i++) { BamlAssemblyInfoRecord assemblyInfo = MapTable.GetAssemblyInfoFromId(assemblyIds[i]); asmNameList[i] = assemblyInfo.AssemblyFullName; } } _xmlnsCache.SetUriToAssemblyNameMapping(xmlNamespace, asmNameList); }
/// <summary> /// Set up the XmlnsCache use for resolving namespaces to use only the assembly path /// table that has been built up by the XamlTypeMapper. /// </summary> internal void InitializeReferenceXmlnsCache() { _xmlnsCache = new XmlnsCache(_assemblyPathTable); }
// Return true if the passed namespace is known, meaning that it maps // to a set of assemblies and clr namespaces internal bool IsXmlNamespaceKnown( string xmlNamespace, out string newXmlNamespace) { bool result; // if the namespace is empty, then there's no need to do all the extra work associated with getting the // namespace map entries. Just return false. if (String.IsNullOrEmpty(xmlNamespace)) { result = false; newXmlNamespace = null; } else { NamespaceMapEntry[] namespaceMaps = GetNamespaceMapEntries(xmlNamespace); if (_xmlnsCache == null) { #if PBTCOMPILER Debug.Assert(false, "Should initialize cache prior to compiling"); #else _xmlnsCache = new XmlnsCache(); #endif } newXmlNamespace = _xmlnsCache.GetNewXmlnamespace(xmlNamespace); // if the xmlNamespace has valid entries or is mapped to another namespace, then it is known. result = (namespaceMaps != null && namespaceMaps.Length > 0) || !String.IsNullOrEmpty(newXmlNamespace); } return result; // return variable isn't needed, just makes debugging easier. }