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.Util;
|
21
|
|
using Seasar.Framework.Util;
|
22
|
|
|
23
|
|
namespace Seasar.Framework.Container.Impl
|
24
|
|
{
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
|
public class ArgDefImpl : IArgDef
|
29
|
|
{
|
30
|
|
private Object value_;
|
31
|
|
private IS2Container container_;
|
32
|
|
private string expression_;
|
33
|
|
private Type argType_;
|
34
|
|
|
35
|
|
private IComponentDef childComponentDef_;
|
36
|
|
private MetaDefSupport metaDefSupport_ = new MetaDefSupport();
|
37
|
|
|
38
|
|
|
39
|
|
|
40
|
|
|
41
|
606
|
public ArgDefImpl()
|
42
|
|
{
|
43
|
|
}
|
44
|
|
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
43
|
public ArgDefImpl(object value)
|
50
|
|
{
|
51
|
43
|
this.value_ = value;
|
52
|
|
}
|
53
|
|
|
54
|
|
#region ArgDef メンバ
|
55
|
|
|
56
|
|
public object Value
|
57
|
|
{
|
58
|
459
|
get
|
59
|
|
{
|
60
|
|
|
61
|
459
|
if(expression_ != null)
|
62
|
|
{
|
63
|
343
|
if(container_.HasComponentDef(expression_))
|
64
|
|
{
|
65
|
91
|
return container_.GetComponent(expression_);
|
66
|
|
}
|
67
|
252
|
else if (IsCharacterString(expression_))
|
68
|
|
{
|
69
|
231
|
return JScriptUtil.Evaluate(expression_, container_);
|
70
|
|
}
|
71
|
21
|
else if (expression_.IndexOf(".") > 0)
|
72
|
|
{
|
73
|
2
|
int lastIndex = expression_.LastIndexOf(".");
|
74
|
2
|
string enumTypeName =
|
75
|
|
expression_.Substring(0, lastIndex);
|
76
|
2
|
Type enumType = ClassUtil.ForName(enumTypeName,
|
77
|
|
AppDomain.CurrentDomain.GetAssemblies());
|
78
|
2
|
if (enumType != null && enumType.IsEnum)
|
79
|
|
{
|
80
|
1
|
return Enum.Parse(enumType, expression_.Substring(lastIndex + 1));
|
81
|
|
}
|
82
|
|
else
|
83
|
|
{
|
84
|
1
|
return JScriptUtil.Evaluate(expression_, container_);
|
85
|
|
}
|
86
|
|
}
|
87
|
|
else
|
88
|
|
{
|
89
|
19
|
return JScriptUtil.Evaluate(expression_, container_);
|
90
|
|
}
|
91
|
|
}
|
92
|
116
|
if(childComponentDef_ != null)
|
93
|
|
{
|
94
|
65
|
return childComponentDef_.GetComponent(argType_);
|
95
|
|
}
|
96
|
51
|
return value_;
|
97
|
|
}
|
98
|
8
|
set
|
99
|
|
{
|
100
|
8
|
value_ = value;
|
101
|
|
}
|
102
|
|
}
|
103
|
|
|
104
|
|
public IS2Container Container
|
105
|
|
{
|
106
|
1
|
get
|
107
|
|
{
|
108
|
|
|
109
|
1
|
return container_;
|
110
|
|
}
|
111
|
656
|
set
|
112
|
|
{
|
113
|
|
|
114
|
656
|
container_ = value;
|
115
|
656
|
if(childComponentDef_ != null)
|
116
|
|
{
|
117
|
203
|
childComponentDef_.Container = value;
|
118
|
|
}
|
119
|
656
|
metaDefSupport_.Container = value;
|
120
|
|
}
|
121
|
|
}
|
122
|
|
|
123
|
|
public string Expression
|
124
|
|
{
|
125
|
383
|
get
|
126
|
|
{
|
127
|
|
|
128
|
383
|
return expression_;
|
129
|
|
}
|
130
|
392
|
set
|
131
|
|
{
|
132
|
|
|
133
|
392
|
expression_ = value;
|
134
|
|
|
135
|
|
}
|
136
|
|
}
|
137
|
|
|
138
|
|
public IComponentDef ChildComponentDef
|
139
|
|
{
|
140
|
203
|
set
|
141
|
|
{
|
142
|
|
|
143
|
203
|
if(container_ != null)
|
144
|
|
{
|
145
|
0
|
value.Container = container_;
|
146
|
|
}
|
147
|
203
|
childComponentDef_ = value;
|
148
|
|
}
|
149
|
|
}
|
150
|
|
|
151
|
|
public Type ArgType
|
152
|
|
{
|
153
|
5
|
set { argType_ = value; }
|
154
|
0
|
get { return argType_; }
|
155
|
|
}
|
156
|
|
|
157
|
|
#endregion
|
158
|
|
|
159
|
|
#region IMetaDefAware メンバ
|
160
|
|
|
161
|
1
|
public void AddMetaDef(IMetaDef metaDef)
|
162
|
|
{
|
163
|
|
|
164
|
1
|
metaDefSupport_.AddMetaDef(metaDef);
|
165
|
|
}
|
166
|
|
|
167
|
|
public int MetaDefSize
|
168
|
|
{
|
169
|
1
|
get
|
170
|
|
{
|
171
|
|
|
172
|
1
|
return metaDefSupport_.MetaDefSize;
|
173
|
|
}
|
174
|
|
}
|
175
|
|
|
176
|
1
|
public IMetaDef GetMetaDef(int index)
|
177
|
|
{
|
178
|
|
|
179
|
1
|
return metaDefSupport_.GetMetaDef(index);
|
180
|
|
}
|
181
|
|
|
182
|
0
|
public IMetaDef GetMetaDef(string name)
|
183
|
|
{
|
184
|
|
|
185
|
|
return metaDefSupport_.GetMetaDef(name);
|
186
|
|
}
|
187
|
|
|
188
|
0
|
public IMetaDef[] GetMetaDefs(string name)
|
189
|
|
{
|
190
|
|
|
191
|
|
return metaDefSupport_.GetMetaDefs(name);
|
192
|
|
}
|
193
|
|
|
194
|
|
#endregion
|
195
|
|
|
196
|
252
|
private bool IsCharacterString(string str)
|
197
|
|
{
|
198
|
0
|
if (str == null) return false;
|
199
|
252
|
if (str.StartsWith("\"") && str.EndsWith("\"") && str.Length >= 2) return true;
|
200
|
21
|
return false;
|
201
|
|
}
|
202
|
|
}
|
203
|
|
}
|
204
|
|
|