Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 157   Methods: 7
NCLOC: 67 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Aop\Impl\MethodInvocationImpl.cs 62.5% 73.7% 71.4% 70.6%
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 System.Collections;
21   using System.Reflection;
22  
23   namespace Seasar.Framework.Aop.Impl
24   {
25   /// <summary>
26   /// IS2MethodInvocationインターフェイスの実装
27   /// </summary>
28   public class MethodInvocationImpl : IS2MethodInvocation
29   {
30   /// <summary>
31   /// 呼び出されるメソッドが属するインスタンス
32   /// </summary>
33   private object target_;
34  
35   /// <summary>
36   /// 呼び出されるメソッド
37   /// </summary>
38   private MethodBase method_;
39  
40   /// <summary>
41   /// メソッドをInterceptするInterceptorの配列
42   /// </summary>
43   private IMethodInterceptor[] interceptors_;
44  
45   /// <summary>
46   /// 処理されているInterceptorの再帰レベル
47   /// </summary>
48   private int interceptorsIndex_ = 1;
49  
50   /// <summary>
51   /// メソッドの引数
52   /// </summary>
53   private object[] arguments_;
54  
55   /// <summary>
56   /// メソッドとそのクラスのインスタンスが属するS2コンテナに関する情報
57   /// </summary>
58   private Hashtable parameters_;
59  
60   /// <summary>
61   /// コンストラクタ
62   /// </summary>
63   /// <param name="target">Interceptされるオブジェクト</param>
64   /// <param name="method">InterceptされるメソッドのMethodBase</param>
65   /// <param name="interceptors">メソッドのInterceptするInterceptor</param>
66   /// <param name="parameters">Interceptされるメソッドとそのクラスのインスタンスが属するS2コンテナに関する情報</param>
67 59 public MethodInvocationImpl(object target,MethodBase method,
68   object[] arguments,IMethodInterceptor[] interceptors,Hashtable parameters)
69   {
70 0 if(target==null) throw new NullReferenceException("target");
71 0 if(method==null) throw new NullReferenceException("method");
72 0 if(interceptors==null) throw new NullReferenceException("interceptors");
73 59 target_ = target;
74 59 method_ = method;
75 59 arguments_ = arguments;
76 59 interceptors_ = interceptors;
77 59 parameters_ = parameters;
78   }
79  
80   #region IMethodInvocation メンバ
81  
82   /// <summary>
83   /// InterceptされるメソッドのMethod
84   /// </summary>
85   public MethodBase Method
86   {
87 17 get
88   {
89 17 return method_;
90   }
91   }
92  
93   /// <summary>
94   /// Interceptされるオブジェクト
95   /// </summary>
96 0 public Object Target
97   {
98   get
99   {
100   return target_;
101   }
102   }
103  
104   /// <summary>
105   /// Interceptされるメソッドの引数
106   /// </summary>
107   public Object[] Arguments
108   {
109 17 get
110   {
111 17 return arguments_;
112   }
113   }
114  
115   /// <summary>
116   /// メソッドの呼び出し
117   /// </summary>
118   /// <remarks>
119   /// 他にチェーンされているInterceptorがあれば、Interceptorを呼び出します(再帰的に呼び出される)。
120   /// 他にチェーンされているInterceptorが無ければ、Interceptされているメソッドを実行します。
121   /// <remarks>
122   /// <returns>Interceptされたメソッドの戻り値</returns>
123 50 public Object Proceed()
124   {
125 50 while(interceptorsIndex_ < interceptors_.Length)
126   {
127   // 他にInterceptorがあれば、Interceptorを呼び出す
128 4 return interceptors_[interceptorsIndex_++].Invoke(this);
129   }
130   // Interceptされたメソッドを実行する
131 46 return method_.Invoke(target_,arguments_);
132   }
133  
134   #endregion
135  
136   #region IS2MethodInvocation メンバ
137  
138   /// <summary>
139   /// メソッドが属するクラスの型情報
140   /// </summary>
141 0 public Type TargetType
142   {
143   get { return target_.GetType(); }
144   }
145  
146   /// <summary>
147   /// メソッドとそのクラスのインスタンスが属するS2コンテナに関する情報
148   /// </summary>
149 1 public object GetParameter(string name)
150   {
151 1 return parameters_[name];
152   }
153  
154   #endregion
155   }
156   }
157