1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using Seasar.Framework.Container.Assembler;
|
21
|
|
using Seasar.Framework.Container.Util;
|
22
|
|
|
23
|
|
namespace Seasar.Framework.Container.Deployer
|
24
|
|
{
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
|
public class AbstractComponentDeployer : IComponentDeployer
|
29
|
|
{
|
30
|
|
private IComponentDef componentDef_;
|
31
|
|
private IConstructorAssembler constructorAssembler_;
|
32
|
|
private IPropertyAssembler propertyAssembler_;
|
33
|
|
private IMethodAssembler initMethodAssembler_;
|
34
|
|
private IMethodAssembler destroyMethodAssembler_;
|
35
|
|
|
36
|
467
|
public AbstractComponentDeployer(IComponentDef componentDef)
|
37
|
|
{
|
38
|
467
|
componentDef_ = componentDef;
|
39
|
467
|
this.SetupAssembler();
|
40
|
|
}
|
41
|
|
|
42
|
|
#region ComponentDeployer メンバ
|
43
|
|
|
44
|
0
|
public virtual object Deploy(Type receiveType)
|
45
|
|
{
|
46
|
|
|
47
|
|
return null;
|
48
|
|
}
|
49
|
|
|
50
|
0
|
public virtual void InjectDependency(object outerComponent)
|
51
|
|
{
|
52
|
|
|
53
|
|
}
|
54
|
|
|
55
|
4
|
public virtual void Init()
|
56
|
|
{
|
57
|
|
|
58
|
|
}
|
59
|
|
|
60
|
|
#endregion
|
61
|
|
|
62
|
0
|
public virtual void Destroy()
|
63
|
|
{
|
64
|
|
|
65
|
|
}
|
66
|
|
|
67
|
847
|
protected object GetProxy(Type receiveType)
|
68
|
|
{
|
69
|
847
|
if(receiveType == null) return null;
|
70
|
726
|
return ComponentDef.GetProxy(receiveType);
|
71
|
|
}
|
72
|
|
|
73
|
|
protected IComponentDef ComponentDef
|
74
|
|
{
|
75
|
916
|
get { return componentDef_; }
|
76
|
|
}
|
77
|
|
|
78
|
|
protected IConstructorAssembler ConstructorAssembler
|
79
|
|
{
|
80
|
465
|
get { return constructorAssembler_; }
|
81
|
|
}
|
82
|
|
|
83
|
|
protected IPropertyAssembler PropertyAssembler
|
84
|
|
{
|
85
|
469
|
get { return propertyAssembler_; }
|
86
|
|
}
|
87
|
|
|
88
|
|
protected IMethodAssembler InitMethodAssembler
|
89
|
|
{
|
90
|
469
|
get { return initMethodAssembler_; }
|
91
|
|
}
|
92
|
|
|
93
|
|
protected IMethodAssembler DestroyMethodAssembler
|
94
|
|
{
|
95
|
139
|
get { return destroyMethodAssembler_; }
|
96
|
|
}
|
97
|
|
|
98
|
467
|
private void SetupAssembler()
|
99
|
|
{
|
100
|
467
|
string autoBindingMode = componentDef_.AutoBindingMode;
|
101
|
467
|
if(AutoBindingUtil.IsAuto(autoBindingMode))
|
102
|
|
{
|
103
|
460
|
this.SetupAssemblerForAuto();
|
104
|
|
}
|
105
|
7
|
else if(AutoBindingUtil.IsConstructor(autoBindingMode))
|
106
|
|
{
|
107
|
1
|
this.SetupAssemblerForConstructor();
|
108
|
|
}
|
109
|
6
|
else if(AutoBindingUtil.IsProperty(autoBindingMode))
|
110
|
|
{
|
111
|
1
|
this.SetupAssemblerForProperty();
|
112
|
|
}
|
113
|
5
|
else if(AutoBindingUtil.IsNone(autoBindingMode))
|
114
|
|
{
|
115
|
5
|
this.SetupAssemblerForNone();
|
116
|
|
}
|
117
|
|
else
|
118
|
|
{
|
119
|
0
|
throw new ArgumentException(autoBindingMode);
|
120
|
|
}
|
121
|
467
|
initMethodAssembler_ = new DefaultInitMethodAssembler(componentDef_);
|
122
|
467
|
destroyMethodAssembler_ = new DefaultDestroyMethodAssembler(componentDef_);
|
123
|
|
}
|
124
|
|
|
125
|
460
|
private void SetupAssemblerForAuto()
|
126
|
|
{
|
127
|
460
|
this.SetupConstructorAssemblerForAuto();
|
128
|
460
|
propertyAssembler_ = new AutoPropertyAssembler(componentDef_);
|
129
|
|
}
|
130
|
|
|
131
|
461
|
private void SetupConstructorAssemblerForAuto()
|
132
|
|
{
|
133
|
461
|
if(componentDef_.ArgDefSize > 0)
|
134
|
|
{
|
135
|
82
|
constructorAssembler_ = new ManualConstructorAssembler(componentDef_);
|
136
|
|
}
|
137
|
379
|
else if(componentDef_.Expression != null)
|
138
|
|
{
|
139
|
52
|
constructorAssembler_ =
|
140
|
|
new ExpressionConstructorAssembler(componentDef_);
|
141
|
|
}
|
142
|
|
else
|
143
|
|
{
|
144
|
327
|
constructorAssembler_ = new AutoConstructorAssembler(componentDef_);
|
145
|
|
}
|
146
|
|
}
|
147
|
|
|
148
|
1
|
private void SetupAssemblerForConstructor()
|
149
|
|
{
|
150
|
1
|
this.SetupConstructorAssemblerForAuto();
|
151
|
1
|
propertyAssembler_ = new ManualPropertyAssembler(componentDef_);
|
152
|
|
}
|
153
|
|
|
154
|
1
|
private void SetupAssemblerForProperty()
|
155
|
|
{
|
156
|
1
|
if(componentDef_.Expression != null)
|
157
|
|
{
|
158
|
0
|
constructorAssembler_ =
|
159
|
|
new ExpressionConstructorAssembler(componentDef_);
|
160
|
|
}
|
161
|
|
else
|
162
|
|
{
|
163
|
1
|
constructorAssembler_ = new ManualConstructorAssembler(componentDef_);
|
164
|
|
}
|
165
|
1
|
propertyAssembler_ = new AutoPropertyAssembler(componentDef_);
|
166
|
|
}
|
167
|
|
|
168
|
5
|
private void SetupAssemblerForNone()
|
169
|
|
{
|
170
|
5
|
if(componentDef_.ArgDefSize > 0)
|
171
|
|
{
|
172
|
1
|
constructorAssembler_ = new ManualConstructorAssembler(componentDef_);
|
173
|
|
}
|
174
|
4
|
else if(componentDef_.Expression != null)
|
175
|
|
{
|
176
|
0
|
constructorAssembler_ =
|
177
|
|
new ExpressionConstructorAssembler(componentDef_);
|
178
|
|
}
|
179
|
|
else
|
180
|
|
{
|
181
|
4
|
constructorAssembler_ = new DefaultConstructorAssembler(componentDef_);
|
182
|
|
}
|
183
|
5
|
if(componentDef_.PropertyDefSize > 0)
|
184
|
|
{
|
185
|
1
|
propertyAssembler_ = new ManualPropertyAssembler(componentDef_);
|
186
|
|
}
|
187
|
|
else
|
188
|
|
{
|
189
|
4
|
propertyAssembler_ = new DefaultPropertyAssembler(componentDef_);
|
190
|
|
}
|
191
|
|
}
|
192
|
|
|
193
|
|
}
|
194
|
|
}
|
195
|
|
|