Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 85   Methods: 3
NCLOC: 62 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Container\Assembler\AutoConstructorAssembler.cs 100.0% 100.0% 100.0% 100.0%
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 System.Reflection;
21   using Seasar.Framework.Util;
22   using Seasar.Framework.Container.Util;
23  
24   namespace Seasar.Framework.Container.Assembler
25   {
26   /// <summary>
27   /// AutoConstructorAssembler の概要の説明です。
28   /// </summary>
29   public class AutoConstructorAssembler : AbstractConstructorAssembler
30   {
31 334 public AutoConstructorAssembler(IComponentDef componentDef)
32   : base(componentDef)
33   {
34   }
35  
36 331 public override object Assemble()
37   {
38 331 ConstructorInfo constructor =this.GetSuitableConstructor();
39 331 object obj;
40 331 if(constructor == null)
41   {
42 317 if(this.ComponentDef.ComponentType.IsInterface)
43   {
44 4 obj = new object();
45   }
46   else
47   {
48 313 return this.AssembleDefault();
49   }
50   }
51   else
52   {
53 14 object[] args = this.GetArgs(
54   ParameterUtil.GetParameterTypes(constructor.GetParameters()));
55 13 obj = ConstructorUtil.NewInstance(constructor,args);
56   }
57 17 if(this.ComponentDef.ComponentType.IsInterface && this.ComponentDef.AspectDefSize > 0)
58   {
59 4 AopProxyUtil.WeaveAspect(ref obj,this.ComponentDef);
60   }
61 17 return obj;
62   }
63  
64 331 private ConstructorInfo GetSuitableConstructor()
65   {
66 331 int argSize = -1;
67 331 ConstructorInfo constructor = null;
68 331 ConstructorInfo[] constructors =
69   this.ComponentDef.ComponentType.GetConstructors();
70 346 for(int i = 0; i < constructors.Length; ++i)
71   {
72 327 int tempArgSize = constructors[i].GetParameters().Length;
73 327 if(tempArgSize == 0) return null;
74 15 if(tempArgSize > argSize
75   && AutoBindingUtil.IsSuitable(constructors[i].GetParameters()))
76   {
77 14 constructor = constructors[i];
78 14 argSize = tempArgSize;
79   }
80   }
81 19 return constructor;
82   }
83   }
84   }
85