Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ConstraintConverter.cs
Go to the documentation of this file.
1
using
System.ComponentModel
;
2
using
System.ComponentModel.Design.Serialization
;
3
using
System.Globalization
;
4
using
System.Reflection
;
5
6
namespace
System.Data
;
7
8
internal
sealed
class
ConstraintConverter
:
ExpandableObjectConverter
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
{
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
}
71
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ComponentModel.Design.Serialization.InstanceDescriptor
Definition
InstanceDescriptor.cs:7
System.ComponentModel.ExpandableObjectConverter
Definition
ExpandableObjectConverter.cs:6
System.Data.ConstraintConverter.CanConvertTo
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
Definition
ConstraintConverter.cs:10
System.Data.ConstraintConverter.ConvertTo
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
Definition
ConstraintConverter.cs:19
System.Data.ConstraintConverter
Definition
ConstraintConverter.cs:9
System.Data.Constraint.ConstraintName
virtual string ConstraintName
Definition
Constraint.cs:24
System.Data.Constraint
Definition
Constraint.cs:11
System.Data.DataTable.TableName
string TableName
Definition
DataTable.cs:706
System.Data.ForeignKeyConstraint.ChildColumnNames
string[] ChildColumnNames
Definition
ForeignKeyConstraint.cs:62
System.Data.ForeignKeyConstraint.ParentColumnNames
string[] ParentColumnNames
Definition
ForeignKeyConstraint.cs:60
System.Data.ForeignKeyConstraint.DeleteRule
virtual Rule DeleteRule
Definition
ForeignKeyConstraint.cs:85
System.Data.ForeignKeyConstraint.ParentKey
DataKey ParentKey
Definition
ForeignKeyConstraint.cs:122
System.Data.ForeignKeyConstraint.AcceptRejectRule
virtual AcceptRejectRule AcceptRejectRule
Definition
ForeignKeyConstraint.cs:66
System.Data.ForeignKeyConstraint
Definition
ForeignKeyConstraint.cs:10
System.Data.UniqueConstraint.ColumnNames
string[] ColumnNames
Definition
UniqueConstraint.cs:20
System.Data.UniqueConstraint
Definition
UniqueConstraint.cs:9
System.Globalization.CultureInfo
Definition
CultureInfo.cs:8
System.Reflection.ConstructorInfo
Definition
ConstructorInfo.cs:8
System.Type
Definition
Type.cs:14
System.ComponentModel.ITypeDescriptorContext
Definition
ITypeDescriptorContext.cs:4
System.ComponentModel.Design.Serialization
Definition
DesignerSerializerAttribute.cs:1
System.ComponentModel
Definition
ColumnAttribute.cs:3
System.Data.Rule
Rule
Definition
Rule.cs:4
System.Data.AcceptRejectRule
AcceptRejectRule
Definition
AcceptRejectRule.cs:4
System.Data
Definition
ADP.cs:12
System.Globalization
Definition
Calendar.cs:1
System.Reflection
Definition
ICustomTypeProvider.cs:1
System.ExceptionArgument.value
@ value
System.ExceptionArgument.culture
@ culture
System.Data.DataKey.Table
DataTable Table
Definition
DataKey.cs:11
source
System.Data.Common
System.Data
ConstraintConverter.cs
Generated by
1.10.0