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.Impl;
|
21
|
|
using Seasar.Framework.Container.Util;
|
22
|
|
using Seasar.Framework.Log;
|
23
|
|
|
24
|
|
namespace Seasar.Framework.Container.Assembler
|
25
|
|
{
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
|
public abstract class AbstractAssembler
|
30
|
|
{
|
31
|
|
private static Logger logger_ = Logger.GetLogger(typeof(AbstractAssembler));
|
32
|
|
private IComponentDef componentDef_;
|
33
|
|
|
34
|
1902
|
public AbstractAssembler(IComponentDef componentDef)
|
35
|
|
{
|
36
|
1902
|
componentDef_ = componentDef;
|
37
|
|
}
|
38
|
|
|
39
|
|
protected IComponentDef ComponentDef
|
40
|
|
{
|
41
|
4852
|
get { return componentDef_; }
|
42
|
|
}
|
43
|
|
|
44
|
0
|
protected Type GetComponentType()
|
45
|
|
{
|
46
|
|
return componentDef_.ComponentType;
|
47
|
|
}
|
48
|
|
|
49
|
1
|
protected Type GetComponentType(object component)
|
50
|
|
{
|
51
|
1
|
Type type = componentDef_.ComponentType;
|
52
|
1
|
if(type != null)
|
53
|
|
{
|
54
|
1
|
return type;
|
55
|
|
}
|
56
|
|
else
|
57
|
|
{
|
58
|
0
|
return component.GetType();
|
59
|
|
}
|
60
|
|
}
|
61
|
|
|
62
|
24
|
protected object[] GetArgs(Type[] argTypes)
|
63
|
|
{
|
64
|
24
|
object[] args = new Object[argTypes.Length];
|
65
|
39
|
for(int i = 0; i < argTypes.Length; i++)
|
66
|
|
{
|
67
|
16
|
try
|
68
|
|
{
|
69
|
16
|
args[i] = this.ComponentDef.Container.GetComponent(argTypes[i]);
|
70
|
|
}
|
71
|
|
catch (ComponentNotFoundRuntimeException ex)
|
72
|
|
{
|
73
|
1
|
logger_.Log("WSSR0007",
|
74
|
|
new object[] {
|
75
|
|
this.ComponentDef.ComponentType.FullName,
|
76
|
|
ex.Message});
|
77
|
1
|
args[i] = null;
|
78
|
|
}
|
79
|
|
}
|
80
|
23
|
return args;
|
81
|
|
}
|
82
|
|
|
83
|
|
|
84
|
|
|
85
|
|
|
86
|
|
|
87
|
|
|
88
|
|
|
89
|
383
|
protected object GetComponentByReceiveType(Type receiveType, string expression)
|
90
|
|
{
|
91
|
383
|
IS2Container container = this.ComponentDef.Container;
|
92
|
383
|
object value = null;
|
93
|
|
|
94
|
383
|
if (AutoBindingUtil.IsSuitable(receiveType) && expression != null
|
95
|
|
&& container.HasComponentDef(expression))
|
96
|
|
{
|
97
|
6
|
IComponentDef cd = container.GetComponentDef(expression);
|
98
|
6
|
value = cd.GetComponent(receiveType);
|
99
|
|
}
|
100
|
|
|
101
|
383
|
return value;
|
102
|
|
}
|
103
|
|
}
|
104
|
|
}
|
105
|
|
|