Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 105   Methods: 6
NCLOC: 70 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Container\Assembler\AbstractAssembler.cs 83.3% 90.0% 83.3% 87.5%
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.Impl;
21   using Seasar.Framework.Container.Util;
22   using Seasar.Framework.Log;
23  
24   namespace Seasar.Framework.Container.Assembler
25   {
26   /// <summary>
27   /// AbstractAssembler の概要の説明です。
28   /// </summary>
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   /// <summary>
84   /// 受け側のTypeを指定してコンポーネントを取得する
85   /// </summary>
86   /// <param name="receiveType">受け側のType</param>
87   /// <param name="expression">expression</param>
88   /// <returns>expressionからコンポーネント定義を探す</returns>
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