Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 204   Methods: 17
NCLOC: 138 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Container\Impl\ArgDefImpl.cs 90.0% 87.5% 82.4% 87.0%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
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   /// <summary>
26   /// 引数を定義します。
27   /// </summary>
28   public class ArgDefImpl : IArgDef
29   {
30   private Object value_;
31   private IS2Container container_;
32   private string expression_;
33   private Type argType_;
34   //private object exp_;
35   private IComponentDef childComponentDef_;
36   private MetaDefSupport metaDefSupport_ = new MetaDefSupport();
37  
38   /// <summary>
39   /// コンストラクタ
40   /// </summary>
41 606 public ArgDefImpl()
42   {
43   }
44  
45   /// <summary>
46   /// コンストラクタ
47   /// </summary>
48   /// <param name="value"></param>
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   //exp_ = null;
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