Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ConstraintConverter.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 base.CanConvertTo(context, destinationType);
15 }
16 return true;
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 if (destinationType == typeof(InstanceDescriptor) && value is Constraint)
26 {
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 }
71}
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
virtual string ConstraintName
Definition Constraint.cs:24
virtual AcceptRejectRule AcceptRejectRule
DataTable Table
Definition DataKey.cs:11