Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OutputScopeManager.cs
Go to the documentation of this file.
2
4
5internal sealed class OutputScopeManager
6{
7 private readonly HWStack _elementScopesStack;
8
9 private string _defaultNS;
10
11 private readonly OutKeywords _atoms;
12
13 private readonly XmlNameTable _nameTable;
14
15 private int _prefixIndex;
16
17 internal string DefaultNamespace => _defaultNS;
18
20
22
23 internal string XmlLang => CurrentElementScope.Lang;
24
39
40 internal void PushNamespace(string prefix, string nspace)
41 {
43 if (prefix == null || prefix.Length == 0)
44 {
46 }
47 }
48
60
61 internal void PopScope()
62 {
65 {
66 _defaultNS = namespaceDecl.PrevDefaultNsUri;
67 }
68 }
69
70 internal string ResolveNamespace(string prefix)
71 {
72 bool thisScope;
74 }
75
76 internal string ResolveNamespace(string prefix, out bool thisScope)
77 {
78 thisScope = true;
79 if (prefix == null || prefix.Length == 0)
80 {
81 return _defaultNS;
82 }
84 {
85 return _atoms.XmlNamespace;
86 }
88 {
90 }
91 for (int num = _elementScopesStack.Length - 1; num >= 0; num--)
92 {
94 string text = outputScope.ResolveAtom(prefix);
95 if (text != null)
96 {
98 return text;
99 }
100 }
101 return null;
102 }
103
104 internal bool FindPrefix(string nspace, out string prefix)
105 {
106 int num = _elementScopesStack.Length - 1;
107 while (0 <= num)
108 {
110 string prefix2 = null;
111 if (outputScope.FindPrefix(nspace, out prefix2))
112 {
113 string text = ResolveNamespace(prefix2);
114 if (text == null || !Ref.Equal(text, nspace))
115 {
116 break;
117 }
118 prefix = prefix2;
119 return true;
120 }
121 num--;
122 }
123 prefix = null;
124 return false;
125 }
126
127 internal string GeneratePrefix(string format)
128 {
129 string array;
130 do
131 {
133 }
134 while (_nameTable.Get(array) != null);
135 return _nameTable.Add(array);
136 }
137}
static CultureInfo InvariantCulture
void AddToTop(object o)
Definition HWStack.cs:90
object Push()
Definition HWStack.cs:52
object Peek()
Definition HWStack.cs:81
static bool Equal(string strA, string strB)
Definition Ref.cs:5
string Add(char[] array, int offset, int length)
string? Get(char[] array, int offset, int length)
NamespaceDecl AddNamespace(string prefix, string uri, string prevDefaultNsUri)
bool FindPrefix(string nspace, out string prefix)
void PushScope(string name, string nspace, string prefix)
void PushNamespace(string prefix, string nspace)
string ResolveNamespace(string prefix, out bool thisScope)
OutputScopeManager(XmlNameTable nameTable, OutKeywords atoms)