Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RelationshipConverter.cs
Go to the documentation of this file.
5
6namespace System.Data;
7
9{
10 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
11 {
12 if (destinationType == typeof(InstanceDescriptor))
13 {
14 return true;
15 }
16 return base.CanConvertTo(context, destinationType);
17 }
18
19 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
20 {
21 if (destinationType == null)
22 {
23 throw new ArgumentNullException("destinationType");
24 }
25 ConstructorInfo constructorInfo = null;
26 object[] array = null;
27 if (destinationType == typeof(InstanceDescriptor) && value is DataRelation)
28 {
29 DataRelation dataRelation = (DataRelation)value;
30 DataTable table = dataRelation.ParentKey.Table;
31 DataTable table2 = dataRelation.ChildKey.Table;
32 if (string.IsNullOrEmpty(table.Namespace) && string.IsNullOrEmpty(table2.Namespace))
33 {
34 constructorInfo = typeof(DataRelation).GetConstructor(new Type[6]
35 {
36 typeof(string),
37 typeof(string),
38 typeof(string),
39 typeof(string[]),
40 typeof(string[]),
41 typeof(bool)
42 });
43 array = new object[6]
44 {
45 dataRelation.RelationName,
46 dataRelation.ParentKey.Table.TableName,
47 dataRelation.ChildKey.Table.TableName,
48 dataRelation.ParentColumnNames,
49 dataRelation.ChildColumnNames,
50 dataRelation.Nested
51 };
52 }
53 else
54 {
55 constructorInfo = typeof(DataRelation).GetConstructor(new Type[8]
56 {
57 typeof(string),
58 typeof(string),
59 typeof(string),
60 typeof(string),
61 typeof(string),
62 typeof(string[]),
63 typeof(string[]),
64 typeof(bool)
65 });
66 array = new object[8]
67 {
68 dataRelation.RelationName,
69 dataRelation.ParentKey.Table.TableName,
70 dataRelation.ParentKey.Table.Namespace,
71 dataRelation.ChildKey.Table.TableName,
72 dataRelation.ChildKey.Table.Namespace,
73 dataRelation.ParentColumnNames,
74 dataRelation.ChildColumnNames,
75 dataRelation.Nested
76 };
77 }
78 return new InstanceDescriptor(constructorInfo, array);
79 }
80 return base.ConvertTo(context, culture, value, destinationType);
81 }
82}
virtual string RelationName
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
DataTable Table
Definition DataKey.cs:11