private static void WrapCachedMapping(NamespaceDeclaration prefix, out ReadOnlyXmlnsMapping readOnlyMapping) { XmlnsMapping mapping = new XmlnsMapping(); XNamespace xmlns = XNamespace.Get(prefix.Namespace); if (!AssemblyCache.XmlnsMappings.TryGetValue(xmlns, out mapping)) { // Match a namespace of the form "clr-namespace:<namespace-name>;assembly=<assembly-name>" Match match = assemblyQualifiedNamespaceRegex.Match(prefix.Namespace); if (match.Success) { mapping.ImportReferences = new HashSet <VisualBasicImportReference>(); mapping.ImportReferences.Add( new VisualBasicImportReference { Assembly = match.Groups["assembly"].Value, Import = match.Groups["namespace"].Value, Xmlns = xmlns }); } else { mapping.ImportReferences = new HashSet <VisualBasicImportReference>(); } AssemblyCache.XmlnsMappings[xmlns] = mapping; } // ReadOnlyXmlnsMapping constructor tolerates an empty mapping being passed in. readOnlyMapping = new ReadOnlyXmlnsMapping(mapping); }
internal ReadOnlyXmlnsMapping(XmlnsMapping mapping) { this.wrappedMapping = mapping; }