Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlILNamespaceAnalyzer.cs
Go to the documentation of this file.
3
5
6internal sealed class XmlILNamespaceAnalyzer
7{
9
10 private bool _addInScopeNmsp;
11
12 private int _cntNmsp;
13
15 {
16 _addInScopeNmsp = false;
17 _cntNmsp = 0;
19 {
21 _nsmgr.AddNamespace(string.Empty, string.Empty);
22 _cntNmsp++;
23 }
26 {
28 }
29 }
30
32 {
33 switch (nd.NodeType)
34 {
35 case QilNodeType.Loop:
36 _addInScopeNmsp = false;
38 break;
39 case QilNodeType.Sequence:
40 {
41 foreach (QilNode item in nd)
42 {
44 }
45 break;
46 }
47 case QilNodeType.Conditional:
48 _addInScopeNmsp = false;
51 break;
52 case QilNodeType.Choice:
53 {
54 _addInScopeNmsp = false;
55 QilList branches = (nd as QilChoice).Branches;
56 for (int i = 0; i < branches.Count; i++)
57 {
59 }
60 break;
61 }
62 case QilNodeType.ElementCtor:
63 {
64 _addInScopeNmsp = true;
66 int cntNmsp = _cntNmsp;
68 {
70 }
72 _addInScopeNmsp = false;
74 break;
75 }
76 case QilNodeType.AttributeCtor:
77 _addInScopeNmsp = false;
79 break;
80 case QilNodeType.NamespaceDecl:
82 break;
83 case QilNodeType.Nop:
85 break;
86 default:
87 _addInScopeNmsp = false;
88 break;
89 }
90 }
91
93 {
94 QilNodeType nodeType = nd.NodeType;
96 string text;
97 string text2;
98 if ((uint)(nodeType - 81) <= 1u)
99 {
101 if (!(qilName != null))
102 {
103 return false;
104 }
106 text2 = qilName.NamespaceUri;
107 nodeKind = ((nd.NodeType == QilNodeType.ElementCtor) ? XPathNodeType.Element : XPathNodeType.Attribute);
108 }
109 else
110 {
111 text = (QilLiteral)nd.Left;
112 text2 = (QilLiteral)nd.Right;
113 nodeKind = XPathNodeType.Namespace;
114 }
115 if ((nd.NodeType == QilNodeType.AttributeCtor && text2.Length == 0) || (text == "xml" && text2 == "http://www.w3.org/XML/1998/namespace"))
116 {
117 XmlILConstructInfo.Write(nd).IsNamespaceInScope = true;
118 return true;
119 }
120 if (!ValidateNames.ValidateName(text, string.Empty, text2, nodeKind, ValidateNames.Flags.CheckPrefixMapping))
121 {
122 return false;
123 }
126 for (int i = 0; i < _cntNmsp; i++)
127 {
129 if ((object)text == prefix)
130 {
131 if ((object)text2 == uri)
132 {
133 XmlILConstructInfo.Write(nd).IsNamespaceInScope = true;
134 }
135 break;
136 }
137 }
138 if (_addInScopeNmsp)
139 {
141 _cntNmsp++;
142 }
143 return true;
144 }
145}
static bool ValidateName(string prefix, string localName, string ns, XPathNodeType nodeKind, Flags flags)
string Add(char[] array, int offset, int length)
bool GetNamespaceDeclaration(int idx, [NotNullWhen(true)] out string prefix, out string uri)
virtual void AddNamespace(string prefix, string uri)
static XmlILConstructInfo Write(QilNode nd)
void Analyze(QilNode nd, bool defaultNmspInScope)