Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Stylesheet.cs
Go to the documentation of this file.
3
5
6internal sealed class Stylesheet
7{
8 private sealed class WhitespaceElement
9 {
10 private readonly int _key;
11
12 private readonly double _priority;
13
14 private bool _preserveSpace;
15
16 internal double Priority => _priority;
17
18 internal int Key => _key;
19
20 internal bool PreserveSpace => _preserveSpace;
21
22 internal WhitespaceElement(int Key, double priority, bool PreserveSpace)
23 {
24 _key = Key;
27 }
28
29 internal void ReplaceValue(bool PreserveSpace)
30 {
32 }
33 }
34
35 private readonly ArrayList _imports = new ArrayList();
36
38
39 private readonly Hashtable _templateNameTable = new Hashtable();
40
42
43 private int _templateCount;
44
46
48
49 private bool _whitespace;
50
51 private readonly Hashtable _scriptObjectTypes = new Hashtable();
52
54
55 internal bool Whitespace => _whitespace;
56
58
60
62
63 internal void AddSpace(Compiler compiler, string query, double Priority, bool PreserveSpace)
64 {
66 if (_queryKeyTable != null)
67 {
69 {
71 whitespaceElement.ReplaceValue(PreserveSpace);
72 return;
73 }
74 }
75 else
76 {
79 }
80 int key = compiler.AddQuery(query);
81 whitespaceElement = new WhitespaceElement(key, Priority, PreserveSpace);
84 }
85
86 internal void SortWhiteSpace()
87 {
88 if (_queryKeyTable != null)
89 {
90 for (int i = 0; i < _whitespaceList.Count; i++)
91 {
92 for (int num = _whitespaceList.Count - 1; num > i; num--)
93 {
96 if (whitespaceElement2.Priority < whitespaceElement.Priority)
97 {
100 }
101 }
102 }
103 _whitespace = true;
104 }
105 if (_imports == null)
106 {
107 return;
108 }
109 for (int num2 = _imports.Count - 1; num2 >= 0; num2--)
110 {
111 Stylesheet stylesheet = (Stylesheet)_imports[num2];
112 if (stylesheet.Whitespace)
113 {
114 stylesheet.SortWhiteSpace();
115 _whitespace = true;
116 }
117 }
118 }
119
121 {
122 if (_whitespaceList != null)
123 {
124 int num = _whitespaceList.Count - 1;
125 while (0 <= num)
126 {
128 if (proc.Matches(node, whitespaceElement.Key))
129 {
130 return whitespaceElement.PreserveSpace;
131 }
132 num--;
133 }
134 }
135 if (_imports != null)
136 {
137 for (int num2 = _imports.Count - 1; num2 >= 0; num2--)
138 {
139 Stylesheet stylesheet = (Stylesheet)_imports[num2];
140 if (!stylesheet.PreserveWhiteSpace(proc, node))
141 {
142 return false;
143 }
144 }
145 }
146 return true;
147 }
148
150 {
151 if (_attributeSetTable == null)
152 {
154 }
156 {
158 }
159 else
160 {
162 }
163 }
164
165 internal void AddTemplate(TemplateAction template)
166 {
167 XmlQualifiedName xmlQualifiedName = template.Mode;
168 if (template.Name != null)
169 {
170 if (_templateNameTable.ContainsKey(template.Name))
171 {
172 throw XsltException.Create(System.SR.Xslt_DupTemplateName, template.Name.ToString());
173 }
174 _templateNameTable[template.Name] = template;
175 }
176 if (template.MatchKey == -1)
177 {
178 return;
179 }
180 if (_modeManagers == null)
181 {
182 _modeManagers = new Hashtable();
183 }
184 if (xmlQualifiedName == null)
185 {
187 }
189 if (templateManager == null)
190 {
193 if (xmlQualifiedName.IsEmpty)
194 {
196 }
197 }
199 templateManager.AddTemplate(template);
200 }
201
202 internal void ProcessTemplates()
203 {
204 if (_modeManagers != null)
205 {
207 while (enumerator.MoveNext())
208 {
210 templateManager.ProcessTemplates();
211 }
212 }
213 if (_imports != null)
214 {
215 for (int num = _imports.Count - 1; num >= 0; num--)
216 {
217 Stylesheet stylesheet = (Stylesheet)_imports[num];
218 stylesheet.ProcessTemplates();
219 }
220 }
221 }
222
224 {
225 if (_modeManagers != null)
226 {
228 while (enumerator.MoveNext())
229 {
231 if (templateManager.templates != null)
232 {
233 for (int i = 0; i < templateManager.templates.Count; i++)
234 {
236 templateAction.ReplaceNamespaceAlias(compiler);
237 }
238 }
239 }
240 }
241 if (_templateNameTable != null)
242 {
244 while (enumerator2.MoveNext())
245 {
247 templateAction2.ReplaceNamespaceAlias(compiler);
248 }
249 }
250 if (_imports != null)
251 {
252 for (int num = _imports.Count - 1; num >= 0; num--)
253 {
254 Stylesheet stylesheet = (Stylesheet)_imports[num];
256 }
257 }
258 }
259
277
279 {
281 if (_imports != null)
282 {
283 for (int num = _imports.Count - 1; num >= 0; num--)
284 {
285 Stylesheet stylesheet = (Stylesheet)_imports[num];
286 templateAction = stylesheet.FindTemplate(processor, navigator, mode);
287 if (templateAction != null)
288 {
289 return templateAction;
290 }
291 }
292 }
293 return templateAction;
294 }
295
309
311 {
313 if (_templateNameTable != null)
314 {
316 }
317 if (templateAction == null && _imports != null)
318 {
319 for (int num = _imports.Count - 1; num >= 0; num--)
320 {
321 Stylesheet stylesheet = (Stylesheet)_imports[num];
322 templateAction = stylesheet.FindTemplate(name);
323 if (templateAction != null)
324 {
325 return templateAction;
326 }
327 }
328 }
329 return templateAction;
330 }
331
333 {
335 if (_imports != null)
336 {
337 for (int num = _imports.Count - 1; num >= 0; num--)
338 {
339 Stylesheet stylesheet = (Stylesheet)_imports[num];
341 if (templateAction != null)
342 {
343 return templateAction;
344 }
345 }
346 }
347 return templateAction;
348 }
349}
virtual int Add(object? value)
virtual bool Contains(object key)
Definition Hashtable.cs:719
IEnumerator IEnumerable. GetEnumerator()
Definition Hashtable.cs:899
virtual bool ContainsKey(object key)
Definition Hashtable.cs:724
static string Xslt_DupTemplateName
Definition SR.cs:1898
Definition SR.cs:7
static readonly XmlQualifiedName Empty
static XsltException Create(string res, params string[] args)
WhitespaceElement(int Key, double priority, bool PreserveSpace)
Definition Stylesheet.cs:22
TemplateAction FindTemplate(Processor processor, XPathNavigator navigator)
bool PreserveWhiteSpace(Processor proc, XPathNavigator node)
TemplateAction FindTemplate(Processor processor, XPathNavigator navigator, XmlQualifiedName mode)
void ReplaceNamespaceAlias(Compiler compiler)
void AddAttributeSet(AttributeSetAction attributeSet)
readonly Hashtable _templateNameTable
Definition Stylesheet.cs:39
TemplateAction FindTemplate(XmlQualifiedName name)
TemplateAction FindTemplateImports(Processor processor, XPathNavigator navigator)
readonly Hashtable _scriptObjectTypes
Definition Stylesheet.cs:51
void AddSpace(Compiler compiler, string query, double Priority, bool PreserveSpace)
Definition Stylesheet.cs:63
TemplateAction FindTemplateImports(Processor processor, XPathNavigator navigator, XmlQualifiedName mode)
void AddTemplate(TemplateAction template)
TemplateAction FindTemplate(Processor processor, XPathNavigator navigator)