Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NestedContainer.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.ComponentModel
;
4
5
public
class
NestedContainer
:
Container
,
INestedContainer
,
IContainer
,
IDisposable
6
{
7
private
sealed
class
Site
:
INestedSite
,
ISite
,
IServiceProvider
8
{
9
private
string
_name
;
10
11
public
IComponent
Component
{
get
; }
12
13
public
IContainer
Container
{
get
; }
14
15
public
bool
DesignMode
16
{
17
get
18
{
19
IComponent
owner = ((
NestedContainer
)
Container
).Owner;
20
if
(owner !=
null
&& owner.
Site
!=
null
)
21
{
22
return
owner.
Site
.
DesignMode
;
23
}
24
return
false
;
25
}
26
}
27
28
public
string
FullName
29
{
30
get
31
{
32
if
(
_name
!=
null
)
33
{
34
string
ownerName = ((
NestedContainer
)
Container
).OwnerName;
35
string
text
=
_name
;
36
if
(ownerName !=
null
)
37
{
38
text
= ownerName +
"."
+
text
;
39
}
40
return
text
;
41
}
42
return
_name
;
43
}
44
}
45
46
public
string
Name
47
{
48
get
49
{
50
return
_name
;
51
}
52
[RequiresUnreferencedCode(
"The Type of components in the container cannot be statically discovered to validate the name."
)]
53
set
54
{
55
if
(
value
==
null
||
_name
==
null
|| !
value
.Equals(
_name
))
56
{
57
((
NestedContainer
)
Container
).ValidateName(
Component
,
value
);
58
_name
=
value
;
59
}
60
}
61
}
62
63
internal
Site
(
IComponent
component,
NestedContainer
container,
string
name)
64
{
65
Component
= component;
66
Container
= container;
67
_name
= name;
68
}
69
70
public
object
GetService
(
Type
service)
71
{
72
if
(!(service == typeof(
ISite
)))
73
{
74
return
((
NestedContainer
)
Container
).GetService(service);
75
}
76
return
this
;
77
}
78
}
79
80
public
IComponent
Owner
{
get
; }
81
82
protected
virtual
string
?
OwnerName
83
{
84
get
85
{
86
string
result =
null
;
87
if
(
Owner
!=
null
&&
Owner
.
Site
!=
null
)
88
{
89
result = ((!(Owner.Site is
INestedSite
nestedSite)) ? Owner.Site.Name : nestedSite.FullName);
90
}
91
return
result;
92
}
93
}
94
95
public
NestedContainer
(
IComponent
owner)
96
{
97
Owner
= owner ??
throw
new
ArgumentNullException
(
"owner"
);
98
Owner.Disposed +=
OnOwnerDisposed
;
99
}
100
101
protected
override
ISite
CreateSite
(
IComponent
component,
string
? name)
102
{
103
if
(component ==
null
)
104
{
105
throw
new
ArgumentNullException
(
"component"
);
106
}
107
return
new
Site
(component,
this
, name);
108
}
109
110
protected
override
void
Dispose
(
bool
disposing)
111
{
112
if
(disposing)
113
{
114
Owner.Disposed -=
OnOwnerDisposed
;
115
}
116
base.Dispose(disposing);
117
}
118
119
protected
override
object
?
GetService
(
Type
service)
120
{
121
if
(service == typeof(
INestedContainer
))
122
{
123
return
this
;
124
}
125
return
base.GetService(service);
126
}
127
128
private
void
OnOwnerDisposed
(
object
sender,
EventArgs
e)
129
{
130
Dispose
();
131
}
132
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.ComponentModel.Component
Definition
Component.cs:5
System.ComponentModel.Container.Dispose
void Dispose()
Definition
Container.cs:152
System.ComponentModel.Container
Definition
Container.cs:6
System.ComponentModel.NestedContainer.Site.Name
string Name
Definition
NestedContainer.cs:47
System.ComponentModel.NestedContainer.Site.GetService
object GetService(Type service)
Definition
NestedContainer.cs:70
System.ComponentModel.NestedContainer.Site.DesignMode
bool DesignMode
Definition
NestedContainer.cs:16
System.ComponentModel.NestedContainer.Site._name
string _name
Definition
NestedContainer.cs:9
System.ComponentModel.NestedContainer.Site.Site
Site(IComponent component, NestedContainer container, string name)
Definition
NestedContainer.cs:63
System.ComponentModel.NestedContainer.Site.FullName
string FullName
Definition
NestedContainer.cs:29
System.ComponentModel.NestedContainer.Site
Definition
NestedContainer.cs:8
System.ComponentModel.NestedContainer.Owner
IComponent Owner
Definition
NestedContainer.cs:80
System.ComponentModel.NestedContainer.CreateSite
override ISite CreateSite(IComponent component, string? name)
Definition
NestedContainer.cs:101
System.ComponentModel.NestedContainer.OwnerName
virtual ? string OwnerName
Definition
NestedContainer.cs:83
System.ComponentModel.NestedContainer.NestedContainer
NestedContainer(IComponent owner)
Definition
NestedContainer.cs:95
System.ComponentModel.NestedContainer.OnOwnerDisposed
void OnOwnerDisposed(object sender, EventArgs e)
Definition
NestedContainer.cs:128
System.ComponentModel.NestedContainer.GetService
override? object GetService(Type service)
Definition
NestedContainer.cs:119
System.ComponentModel.NestedContainer.Dispose
override void Dispose(bool disposing)
Definition
NestedContainer.cs:110
System.ComponentModel.NestedContainer
Definition
NestedContainer.cs:6
System.EventArgs
Definition
EventArgs.cs:8
System.Type
Definition
Type.cs:14
System.ComponentModel.IComponent.Site
ISite? Site
Definition
IComponent.cs:8
System.ComponentModel.IComponent
Definition
IComponent.cs:7
System.ComponentModel.IContainer
Definition
IContainer.cs:6
System.ComponentModel.INestedContainer
Definition
INestedContainer.cs:4
System.ComponentModel.INestedSite
Definition
INestedSite.cs:4
System.ComponentModel.ISite.DesignMode
bool DesignMode
Definition
ISite.cs:11
System.ComponentModel.ISite
Definition
ISite.cs:6
System.IDisposable
Definition
IDisposable.cs:4
System.IServiceProvider
Definition
IServiceProvider.cs:4
System.ComponentModel
Definition
ColumnAttribute.cs:3
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.ExceptionArgument.text
@ text
System.ExceptionArgument.value
@ value
source
System.ComponentModel.TypeConverter
System.ComponentModel
NestedContainer.cs
Generated by
1.10.0