Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RelationshipConverter.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
RelationshipConverter
:
ExpandableObjectConverter
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
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ComponentModel.Design.Serialization.InstanceDescriptor
Definition
InstanceDescriptor.cs:7
System.ComponentModel.ExpandableObjectConverter
Definition
ExpandableObjectConverter.cs:6
System.Data.DataRelation.ParentKey
DataKey ParentKey
Definition
DataRelation.cs:114
System.Data.DataRelation.ChildColumnNames
string[] ChildColumnNames
Definition
DataRelation.cs:100
System.Data.DataRelation.RelationName
virtual string RelationName
Definition
DataRelation.cs:133
System.Data.DataRelation.ChildKey
DataKey ChildKey
Definition
DataRelation.cs:70
System.Data.DataRelation.ParentColumnNames
string[] ParentColumnNames
Definition
DataRelation.cs:98
System.Data.DataRelation
Definition
DataRelation.cs:14
System.Data.DataTable.Namespace
string Namespace
Definition
DataTable.cs:794
System.Data.DataTable.TableName
string TableName
Definition
DataTable.cs:706
System.Data.DataTable
Definition
DataTable.cs:29
System.Data.RelationshipConverter.ConvertTo
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
Definition
RelationshipConverter.cs:19
System.Data.RelationshipConverter.CanConvertTo
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
Definition
RelationshipConverter.cs:10
System.Data.RelationshipConverter
Definition
RelationshipConverter.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
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.ExceptionArgument.array
@ array
System.Data.DataKey.Table
DataTable Table
Definition
DataKey.cs:11
source
System.Data.Common
System.Data
RelationshipConverter.cs
Generated by
1.10.0