Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlToDatasetMap.cs
Go to the documentation of this file.
3using System.Xml;
4
5namespace System.Data;
6
7internal sealed class XmlToDatasetMap
8{
9 private sealed class XmlNodeIdentety
10 {
11 public string LocalName;
12
13 public string NamespaceURI;
14
15 public XmlNodeIdentety(string localName, string namespaceURI)
16 {
17 LocalName = localName;
19 }
20
21 public override int GetHashCode()
22 {
23 return LocalName.GetHashCode();
24 }
25
26 public override bool Equals([NotNullWhen(true)] object obj)
27 {
29 if (string.Equals(LocalName, xmlNodeIdentety.LocalName, StringComparison.OrdinalIgnoreCase))
30 {
31 return string.Equals(NamespaceURI, xmlNodeIdentety.NamespaceURI, StringComparison.OrdinalIgnoreCase);
32 }
33 return false;
34 }
35 }
36
37 internal sealed class XmlNodeIdHashtable : Hashtable
38 {
39 private readonly XmlNodeIdentety _id = new XmlNodeIdentety(string.Empty, string.Empty);
40
41 public object this[XmlNode node]
42 {
43 get
44 {
45 _id.LocalName = node.LocalName;
46 _id.NamespaceURI = node.NamespaceURI;
47 return this[_id];
48 }
49 }
50
51 public object this[XmlReader dataReader]
52 {
53 get
54 {
55 _id.LocalName = dataReader.LocalName;
56 _id.NamespaceURI = dataReader.NamespaceURI;
57 return this[_id];
58 }
59 }
60
61 public object this[DataTable table]
62 {
63 get
64 {
65 _id.LocalName = table.EncodedTableName;
66 _id.NamespaceURI = table.Namespace;
67 return this[_id];
68 }
69 }
70
71 public object this[string name]
72 {
73 get
74 {
75 _id.LocalName = name;
76 _id.NamespaceURI = string.Empty;
77 return this[_id];
78 }
79 }
80
82 : base(capacity)
83 {
84 }
85 }
86
99
101
103
108
113
118
123
124 internal static bool IsMappedColumn(DataColumn c)
125 {
126 return c.ColumnMapping != MappingType.Hidden;
127 }
128
130 {
131 string text = nameTable.Get(table.EncodedTableName);
132 string namespaceURI = nameTable.Get(table.Namespace);
133 if (text == null)
134 {
135 return null;
136 }
139 return tableSchemaInfo;
140 }
141
143 {
144 string encodedTableName = table.EncodedTableName;
145 string text = nameTable.Get(encodedTableName);
146 if (text == null)
147 {
149 }
151 string text2 = nameTable.Get(table.Namespace);
152 if (text2 == null)
153 {
154 text2 = nameTable.Add(table.Namespace);
155 }
156 else if (table._tableNamespace != null)
157 {
159 }
162 return tableSchemaInfo;
163 }
164
166 {
167 string text = nameTable.Get(col.EncodedColumnName);
168 string namespaceURI = nameTable.Get(col.Namespace);
169 if (text == null)
170 {
171 return false;
172 }
174 columns[key] = col;
175 if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase))
176 {
178 }
179 return true;
180 }
181
183 {
184 string array = XmlConvert.EncodeLocalName(col.ColumnName);
185 string text = nameTable.Get(array);
186 if (text == null)
187 {
188 text = nameTable.Add(array);
189 }
191 string text2 = nameTable.Get(col.Namespace);
192 if (text2 == null)
193 {
194 text2 = nameTable.Add(col.Namespace);
195 }
196 else if (col._columnUri != null)
197 {
199 }
201 columns[key] = col;
202 if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase))
203 {
205 }
206 return true;
207 }
208
209 [MemberNotNull("_tableSchemaMap")]
211 {
212 _tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count);
213 foreach (DataTable table in dataSet.Tables)
214 {
216 if (tableSchemaInfo == null)
217 {
218 continue;
219 }
220 foreach (DataColumn column in table.Columns)
221 {
223 {
225 }
226 }
227 }
228 }
229
230 [MemberNotNull("_tableSchemaMap")]
232 {
233 _tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count);
234 string text = nameTable.Get(dataSet.Namespace);
235 if (text == null)
236 {
237 text = nameTable.Add(dataSet.Namespace);
238 }
240 foreach (DataTable table in dataSet.Tables)
241 {
243 if (tableSchemaInfo == null)
244 {
245 continue;
246 }
247 foreach (DataColumn column in table.Columns)
248 {
250 {
252 }
253 }
254 foreach (DataRelation childRelation in table.ChildRelations)
255 {
256 if (childRelation.Nested)
257 {
258 string array = XmlConvert.EncodeLocalName(childRelation.ChildTable.TableName);
259 string text2 = nameTable.Get(array);
260 if (text2 == null)
261 {
262 text2 = nameTable.Add(array);
263 }
264 string text3 = nameTable.Get(childRelation.ChildTable.Namespace);
265 if (text3 == null)
266 {
267 text3 = nameTable.Add(childRelation.ChildTable.Namespace);
268 }
270 tableSchemaInfo.ColumnsSchemaMap[key] = childRelation.ChildTable;
271 }
272 }
273 }
274 }
275
276 [MemberNotNull("_tableSchemaMap")]
278 {
281 if (tableSchemaInfo == null)
282 {
283 return;
284 }
285 foreach (DataColumn column in dataTable.Columns)
286 {
288 {
290 }
291 }
292 }
293
294 [MemberNotNull("_tableSchemaMap")]
296 {
300 {
302 if (tableSchemaInfo == null)
303 {
304 continue;
305 }
306 foreach (DataColumn column in item.Columns)
307 {
309 {
311 }
312 }
313 foreach (DataRelation childRelation in item.ChildRelations)
314 {
315 if (childRelation.Nested)
316 {
317 string array = XmlConvert.EncodeLocalName(childRelation.ChildTable.TableName);
318 string text = nameTable.Get(array);
319 if (text == null)
320 {
321 text = nameTable.Add(array);
322 }
323 string text2 = nameTable.Get(childRelation.ChildTable.Namespace);
324 if (text2 == null)
325 {
326 text2 = nameTable.Add(childRelation.ChildTable.Namespace);
327 }
329 tableSchemaInfo.ColumnsSchemaMap[key] = childRelation.ChildTable;
330 }
331 }
332 }
333 }
334
336 {
338 arrayList.Add(dt);
339 for (int i = 0; i < arrayList.Count; i++)
340 {
341 foreach (DataRelation childRelation in ((DataTable)arrayList[i]).ChildRelations)
342 {
343 if (!arrayList.Contains(childRelation.ChildTable))
344 {
345 arrayList.Add(childRelation.ChildTable);
346 }
347 }
348 }
349 return arrayList;
350 }
351
353 {
355 XmlNode xmlNode = ((node.NodeType == XmlNodeType.Attribute) ? ((XmlAttribute)node).OwnerElement : node.ParentNode);
356 do
357 {
358 if (xmlNode == null || xmlNode.NodeType != XmlNodeType.Element)
359 {
360 return null;
361 }
364 }
365 while (tableSchemaInfo == null);
367 {
368 return tableSchemaInfo.ColumnsSchemaMap[node.LocalName];
369 }
370 return tableSchemaInfo.ColumnsSchemaMap[node];
371 }
372
385
387 {
389 if (node.NodeType == XmlNodeType.Element)
390 {
392 }
393 if (tableSchemaInfo != null)
394 {
396 }
398 }
399
410
412 {
413 string text = (('x' != col.ColumnName[0]) ? "_x0058_" : "_x0078_");
414 text += col.ColumnName.AsSpan(1);
415 if (nameTable.Get(text) == null)
416 {
417 nameTable.Add(text);
418 }
419 string namespaceURI = nameTable.Get(col.Namespace);
421 columns[key] = col;
422 }
423}
DataColumnCollection Columns
Definition DataTable.cs:327
DataRelationCollection ChildRelations
Definition DataTable.cs:324
override bool Equals([NotNullWhen(true)] object obj)
XmlNodeIdentety(string localName, string namespaceURI)
DataTable GetTableForNode(XmlReader node, bool fIgnoreNamespace)
object GetSchemaForNode(XmlNode node, bool fIgnoreNamespace)
bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns)
XmlToDatasetMap(XmlNameTable nameTable, DataSet dataSet)
bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns)
void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable)
ArrayList GetSelfAndDescendants(DataTable dt)
object GetColumnSchema(DataTable table, XmlReader dataReader, bool fIgnoreNamespace)
XmlToDatasetMap(DataSet dataSet, XmlNameTable nameTable)
void HandleSpecialColumn(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns)
XmlNodeIdHashtable _tableSchemaMap
static bool IsMappedColumn(DataColumn c)
void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable)
XmlToDatasetMap(DataTable dataTable, XmlNameTable nameTable)
void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet)
object GetColumnSchema(XmlNode node, bool fIgnoreNamespace)
TableSchemaInfo AddTableSchema(XmlNameTable nameTable, DataTable table)
XmlToDatasetMap(XmlNameTable nameTable, DataTable dataTable)
void BuildIdentityMap(DataSet dataSet, XmlNameTable nameTable)
TableSchemaInfo AddTableSchema(DataTable table, XmlNameTable nameTable)
TableSchemaInfo _lastTableSchemaInfo
static ? string EncodeLocalName(string? name)
Definition XmlConvert.cs:49
virtual ? XmlNode ParentNode
Definition XmlNode.cs:76