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

◆ HandleColumn()

void System.Data.XDRSchema.HandleColumn ( XmlElement node,
DataTable table )
inlinepackage

Definition at line 295 of file XDRSchema.cs.

296 {
297 int minOccurs = 0;
298 int maxOccurs = 1;
299 string name;
300 DataColumn dataColumn;
301 if (node.Attributes.Count > 0)
302 {
303 string attribute = node.GetAttribute("ref");
304 if (attribute != null && attribute.Length > 0)
305 {
306 return;
307 }
308 string text = (name = GetInstanceName(node));
309 dataColumn = table.Columns[name, _schemaUri];
310 if (dataColumn != null)
311 {
312 if (dataColumn.ColumnMapping == MappingType.Attribute)
313 {
314 if (XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))
315 {
316 throw ExceptionBuilder.DuplicateDeclaration(text);
317 }
318 }
319 else if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
320 {
321 throw ExceptionBuilder.DuplicateDeclaration(text);
322 }
323 name = XMLSchema.GenUniqueColumnName(text, table);
324 }
325 }
326 else
327 {
328 name = string.Empty;
329 }
331 SimpleType simpleType = null;
332 string attribute2;
333 if (xmlElement == null)
334 {
335 attribute2 = node.GetAttribute("type");
336 throw ExceptionBuilder.UndefinedDatatype(attribute2);
337 }
338 attribute2 = xmlElement.GetAttribute("type", "urn:schemas-microsoft-com:datatypes");
339 string attribute3 = xmlElement.GetAttribute("values", "urn:schemas-microsoft-com:datatypes");
340 Type type;
341 if (attribute2 == null || attribute2.Length == 0)
342 {
343 attribute2 = string.Empty;
344 type = typeof(string);
345 }
346 else
347 {
349 if (attribute2 == "float")
350 {
351 attribute2 = string.Empty;
352 }
353 if (attribute2 == "char")
354 {
355 attribute2 = string.Empty;
356 simpleType = SimpleType.CreateSimpleType(StorageType.Char, type);
357 }
358 if (attribute2 == "enumeration")
359 {
360 attribute2 = string.Empty;
361 simpleType = SimpleType.CreateEnumeratedType(attribute3);
362 }
363 if (attribute2 == "bin.base64")
364 {
365 attribute2 = string.Empty;
366 simpleType = SimpleType.CreateByteArrayType("base64");
367 }
368 if (attribute2 == "bin.hex")
369 {
370 attribute2 = string.Empty;
371 simpleType = SimpleType.CreateByteArrayType("hex");
372 }
373 }
374 bool flag = XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data");
376 string text2 = null;
377 text2 = node.GetAttribute("default");
378 bool flag2 = false;
379 dataColumn = new DataColumn(XmlConvert.DecodeName(name), type, null, (!flag) ? MappingType.Element : MappingType.Attribute);
380 XMLSchema.SetProperties(dataColumn, node.Attributes);
385 if (node.Attributes != null)
386 {
387 for (int i = 0; i < node.Attributes.Count; i++)
388 {
389 if (node.Attributes[i].NamespaceURI == "urn:schemas-microsoft-com:xml-msdata" && node.Attributes[i].LocalName == "Expression")
390 {
391 dataColumn.Expression = node.Attributes[i].Value;
392 break;
393 }
394 }
395 }
396 string attribute4 = node.GetAttribute("targetNamespace");
397 if (attribute4 != null && attribute4.Length > 0)
398 {
400 }
401 table.Columns.Add(dataColumn);
402 if (text2 != null && text2.Length != 0)
403 {
404 try
405 {
407 }
408 catch (FormatException)
409 {
410 throw ExceptionBuilder.CannotConvert(text2, type.FullName);
411 }
412 }
413 }
static object ChangeTypeForXML(object value, Type type)
string GetInstanceName(XmlElement node)
Definition XDRSchema.cs:272
XmlElement FindTypeNode(XmlElement node)
Definition XDRSchema.cs:122
Type ParseDataType(string dt, string dtValues)
Definition XDRSchema.cs:252
void GetMinMax(XmlElement elNode, ref int minOccurs, ref int maxOccurs)
Definition XDRSchema.cs:415
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XDRSchema._schemaUri, System.Data.DataColumnCollection.Add(), System.Data.ExceptionBuilder.CannotConvert(), System.Data.Common.SqlConvert.ChangeTypeForXML(), System.Data.DataTable.Columns, System.Data.SimpleType.CreateByteArrayType(), System.Data.SimpleType.CreateEnumeratedType(), System.Data.SimpleType.CreateSimpleType(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.ExceptionBuilder.DuplicateDeclaration(), System.Data.XMLSchema.FEqualIdentity(), System.Data.XDRSchema.FindTypeNode(), System.Data.XMLSchema.GenUniqueColumnName(), System.Data.XDRSchema.GetInstanceName(), System.Data.XDRSchema.GetMinMax(), System.Data.XDRSchema.ParseDataType(), System.Data.XMLSchema.SetProperties(), System.text, System.type, and System.Data.ExceptionBuilder.UndefinedDatatype().

Referenced by System.Data.XDRSchema.HandleTypeNode(), and System.Data.XDRSchema.InstantiateSimpleTable().