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

◆ ConvertTo() [1/3]

override object System.Data.ConstraintConverter.ConvertTo ( ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType )
inline

Definition at line 19 of file ConstraintConverter.cs.

20 {
21 if (destinationType == null)
22 {
23 throw new ArgumentNullException("destinationType");
24 }
25 if (destinationType == typeof(InstanceDescriptor) && value is Constraint)
26 {
27 if (value is UniqueConstraint)
28 {
29 UniqueConstraint uniqueConstraint = (UniqueConstraint)value;
30 ConstructorInfo constructor = typeof(UniqueConstraint).GetConstructor(new Type[3]
31 {
32 typeof(string),
33 typeof(string[]),
34 typeof(bool)
35 });
36 if (constructor != null)
37 {
38 return new InstanceDescriptor(constructor, new object[3] { uniqueConstraint.ConstraintName, uniqueConstraint.ColumnNames, uniqueConstraint.IsPrimaryKey });
39 }
40 }
41 else
42 {
43 ForeignKeyConstraint foreignKeyConstraint = (ForeignKeyConstraint)value;
44 ConstructorInfo constructor2 = typeof(ForeignKeyConstraint).GetConstructor(new Type[7]
45 {
46 typeof(string),
47 typeof(string),
48 typeof(string[]),
49 typeof(string[]),
50 typeof(AcceptRejectRule),
51 typeof(Rule),
52 typeof(Rule)
53 });
54 if (constructor2 != null)
55 {
56 return new InstanceDescriptor(constructor2, new object[7]
57 {
58 foreignKeyConstraint.ConstraintName,
59 foreignKeyConstraint.ParentKey.Table.TableName,
60 foreignKeyConstraint.ParentColumnNames,
61 foreignKeyConstraint.ChildColumnNames,
62 foreignKeyConstraint.AcceptRejectRule,
63 foreignKeyConstraint.DeleteRule,
64 foreignKeyConstraint.UpdateRule
65 });
66 }
67 }
68 }
69 return base.ConvertTo(context, culture, value, destinationType);
70 }

References System.Data.ForeignKeyConstraint.AcceptRejectRule, System.Data.ForeignKeyConstraint.ChildColumnNames, System.Data.UniqueConstraint.ColumnNames, System.Data.Constraint.ConstraintName, System.culture, System.Data.ForeignKeyConstraint.DeleteRule, System.Data.ForeignKeyConstraint.ParentColumnNames, System.Data.ForeignKeyConstraint.ParentKey, System.Data.DataKey.Table, System.Data.DataTable.TableName, and System.value.