Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetContext()

XmlParserContext System.Xml.XmlLoader.GetContext ( XmlNode node)
inlineprivate

Definition at line 564 of file XmlLoader.cs.

565 {
566 string text = null;
567 XmlSpace xmlSpace = XmlSpace.None;
568 XmlDocumentType documentType = _doc.DocumentType;
569 string baseURI = _doc.BaseURI;
571 XmlNameTable nameTable = _doc.NameTable;
572 XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(nameTable);
573 bool flag = false;
574 while (node != null && node != _doc)
575 {
576 if (node is XmlElement { HasAttributes: not false } xmlElement)
577 {
578 xmlNamespaceManager.PushScope();
579 foreach (XmlAttribute attribute in xmlElement.Attributes)
580 {
581 if (attribute.Prefix == _doc.strXmlns && !hashSet.Contains(attribute.LocalName))
582 {
583 hashSet.Add(attribute.LocalName);
584 xmlNamespaceManager.AddNamespace(attribute.LocalName, attribute.Value);
585 }
586 else if (!flag && attribute.Prefix.Length == 0 && attribute.LocalName == _doc.strXmlns)
587 {
588 xmlNamespaceManager.AddNamespace(string.Empty, attribute.Value);
589 flag = true;
590 }
591 else if (xmlSpace == XmlSpace.None && attribute.Prefix == _doc.strXml && attribute.LocalName == _doc.strSpace)
592 {
593 if (attribute.Value == "default")
594 {
595 xmlSpace = XmlSpace.Default;
596 }
597 else if (attribute.Value == "preserve")
598 {
599 xmlSpace = XmlSpace.Preserve;
600 }
601 }
602 else if (text == null && attribute.Prefix == _doc.strXml && attribute.LocalName == _doc.strLang)
603 {
604 text = attribute.Value;
605 }
606 }
607 }
608 node = node.ParentNode;
609 }
610 return new XmlParserContext(nameTable, xmlNamespaceManager, documentType?.Name, documentType?.PublicId, documentType?.SystemId, documentType?.InternalSubset, baseURI, text, xmlSpace);
611 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
virtual ? XmlDocumentType DocumentType
override string BaseURI
XmlDocument _doc
Definition XmlLoader.cs:9

References System.Xml.XmlLoader._doc, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.XmlDocument.BaseURI, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.Xml.Dictionary, System.Xml.XmlDocument.DocumentType, System.Xml.Name, System.Xml.XmlDocument.NameTable, System.Xml.XmlDocument.strLang, System.Xml.XmlDocument.strSpace, System.Xml.XmlDocument.strXml, System.Xml.XmlDocument.strXmlns, and System.text.

Referenced by System.Xml.XmlLoader.ParsePartialContent().