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

◆ HandleRelation()

void System.Data.XSDSchema.HandleRelation ( XmlElement node,
bool fNested )
inlinepackage

Definition at line 387 of file XSDSchema.cs.

388 {
389 bool createConstraints = false;
390 DataRelationCollection relations = _ds.Relations;
391 string text = XmlConvert.DecodeName(node.GetAttribute("name"));
392 for (int i = 0; i < relations.Count; i++)
393 {
394 if (string.Equals(relations[i].RelationName, text, StringComparison.Ordinal))
395 {
396 return;
397 }
398 }
399 string attribute = node.GetAttribute("parent", "urn:schemas-microsoft-com:xml-msdata");
400 if (attribute == null || attribute.Length == 0)
401 {
402 throw ExceptionBuilder.RelationParentNameMissing(text);
403 }
405 string attribute2 = node.GetAttribute("child", "urn:schemas-microsoft-com:xml-msdata");
406 if (attribute2 == null || attribute2.Length == 0)
407 {
408 throw ExceptionBuilder.RelationChildNameMissing(text);
409 }
411 string attribute3 = node.GetAttribute("parentkey", "urn:schemas-microsoft-com:xml-msdata");
412 if (attribute3 == null || attribute3.Length == 0)
413 {
414 throw ExceptionBuilder.RelationTableKeyMissing(text);
415 }
416 string[] array = attribute3.TrimEnd(null).Split(' ', '+');
417 attribute3 = node.GetAttribute("childkey", "urn:schemas-microsoft-com:xml-msdata");
418 if (attribute3 == null || attribute3.Length == 0)
419 {
420 throw ExceptionBuilder.RelationChildKeyMissing(text);
421 }
422 string[] array2 = attribute3.TrimEnd(null).Split(' ', '+');
423 int num = array.Length;
424 if (num != array2.Length)
425 {
426 throw ExceptionBuilder.MismatchKeyLength();
427 }
428 DataColumn[] array3 = new DataColumn[num];
429 DataColumn[] array4 = new DataColumn[num];
430 string attribute4 = node.GetAttribute("ParentTableNamespace", "urn:schemas-microsoft-com:xml-msdata");
431 string attribute5 = node.GetAttribute("ChildTableNamespace", "urn:schemas-microsoft-com:xml-msdata");
433 if (tableSmart == null)
434 {
435 throw ExceptionBuilder.ElementTypeNotFound(attribute);
436 }
438 if (tableSmart2 == null)
439 {
440 throw ExceptionBuilder.ElementTypeNotFound(attribute2);
441 }
442 for (int j = 0; j < num; j++)
443 {
445 if (array3[j] == null)
446 {
447 throw ExceptionBuilder.ElementTypeNotFound(array[j]);
448 }
450 if (array4[j] == null)
451 {
452 throw ExceptionBuilder.ElementTypeNotFound(array2[j]);
453 }
454 }
455 DataRelation dataRelation = new DataRelation(text, array3, array4, createConstraints);
459 if (FromInference && dataRelation.Nested)
460 {
461 _tableDictionary[dataRelation.ParentTable].Add(dataRelation.ChildTable);
462 }
463 }
void Add(TKey key, TValue value)
DataRelationCollection Relations
Definition DataSet.cs:393
DataTableCollection Tables
Definition DataSet.cs:396
DataTable GetTableSmart(string name, string ns)
Dictionary< DataTable, List< DataTable > > _tableDictionary
Definition XSDSchema.cs:63
static void SetExtProperties(object instance, XmlAttribute[] attrs)
Definition XSDSchema.cs:282
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._ds, System.Data.XSDSchema._tableDictionary, System.Data.DataRelationCollection.Add(), System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.array, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.ExceptionBuilder.ElementTypeNotFound(), System.Data.XSDSchema.FromInference, System.Data.DataTableCollection.GetTableSmart(), System.Data.ExceptionBuilder.MismatchKeyLength(), System.Data.ExceptionBuilder.RelationChildKeyMissing(), System.Data.ExceptionBuilder.RelationChildNameMissing(), System.Data.ExceptionBuilder.RelationParentNameMissing(), System.Data.DataSet.Relations, System.Data.ExceptionBuilder.RelationTableKeyMissing(), System.Data.XSDSchema.SetExtProperties(), System.Data.DataSet.Tables, and System.text.

Referenced by System.Data.XSDSchema.HandleRelations().