Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 186   Methods: 8
NCLOC: 122 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Aop\Proxy\DynamicAopProxy.cs 0.0% 0.0% 0.0% 0.0%
coverage
1   #region using directives
2  
3   using System;
4   using System.Diagnostics;
5   using System.Text;
6   using System.Reflection;
7   using System.Collections;
8  
9   using Seasar.Framework.Aop.Impl;
10   using Seasar.Framework.Util;
11   using Seasar.Framework.Aop.Interceptors;
12   using Seasar.Framework.Container.Util;
13  
14   using Castle.DynamicProxy;
15  
16   #endregion
17  
18   namespace Seasar.Framework.Aop.Proxy
19   {
20   /// <summary>
21   /// Castle.DynamicProxyを使用した、Aspect実行のためのプロキシクラス
22   /// </summary>
23   /// <author>Kazz
24   /// </author>
25   /// <version>1.3 2006/05/23</version>
26   ///
27   [Serializable]
28   public class DynamicAopProxy : IInterceptor
29   {
30   #region fields
31  
32   private ProxyGenerator generator;
33  
34   private object target;
35   private IAspect[] aspects;
36   private Type type;
37   private Hashtable parameters;
38  
39   #endregion
40   #region constructors
41  
42   /// <summary>
43   /// コンストラクタ
44   /// </summary>
45   /// <param name="type">Aspectが摘要される型</param>
46 0 public DynamicAopProxy(Type type)
47   : this(type, null)
48   {
49   }
50  
51   /// <summary>
52   /// コンストラクタ
53   /// </summary>
54   /// <param name="type">Aspectが摘要される型</param>
55   /// <param name="aspects">摘要するAspectの配列</param>
56 0 public DynamicAopProxy(Type type, IAspect[] aspects)
57   : this(type, aspects, null)
58   {
59   }
60  
61   /// <summary>
62   /// コンストラクタ
63   /// </summary>
64   /// <param name="type">Aspectが摘要される型</param>
65   /// <param name="aspects">摘要するAspectの配列</param>
66   /// <param name="parameters">パラメータ</param>
67 0 public DynamicAopProxy(Type type, IAspect[] aspects, Hashtable parameters)
68   : this(type, aspects, parameters, null)
69   {
70   }
71  
72   /// <summary>
73   /// コンストラクタ
74   /// </summary>
75   /// <param name="type">Aspectが摘要される型</param>
76   /// <param name="aspects">摘要するAspectの配列</param>
77   /// <param name="parameters">パラメータ</param>
78   /// <param name="target">Aspectが摘要されるターゲット</param>
79 0 public DynamicAopProxy(Type type, IAspect[] aspects, Hashtable parameters, object target)
80   {
81   this.type = type;
82   this.target = target;
83   if (this.target == null) this.target = new object();
84   this.aspects = aspects;
85   this.parameters = parameters;
86   this.generator = new ProxyGenerator();
87   }
88  
89   #endregion
90   #region public method
91  
92   /// <summary>
93   /// プロキシオブジェクトを生成します
94   /// </summary>
95 0 public object Create()
96   {
97   object result = null;
98   if (this.type.IsInterface)
99   {
100   result = this.generator.CreateProxy(this.type, this, this.target);
101   }
102   else
103   {
104   result = this.generator.CreateClassProxy(this.type, this, new object[] { });
105  
106   }
107   return result;
108   }
109  
110   /// <summary>
111   /// プロキシオブジェクトを生成します
112   /// </summary>
113   /// <param name="argTypes">パラメタ型の配列</param>
114   /// <param name="args">生成時のパラメタの配列</param>
115 0 public object Create(Type[] argTypes, object[] args)
116   {
117   object result = null;
118   if (this.type.IsInterface)
119   {
120   result = this.generator.CreateProxy(this.type, this, args);
121   }
122   else
123   {
124   result = this.generator.CreateClassProxy(this.type, this, args);
125   }
126   return result;
127   }
128   /// <summary>
129   /// プロキシオブジェクトを生成します
130   /// </summary>
131   /// <param name="argTypes">パラメタ型の配列</param>
132   /// <param name="args">生成時のパラメタの配列</param>
133   /// <param name="targetType">ターゲットの型</param>
134 0 public object Create(Type[] argTypes, object[] args, Type targetType)
135   {
136   object result = null;
137   if (this.type.IsInterface)
138   {
139   result = this.generator.CreateProxy(targetType, this, args);
140   }
141   else
142   {
143   result = this.generator.CreateClassProxy(targetType, this, args);
144   }
145   return result;
146   }
147  
148   #endregion
149   #region IInterceptor member
150  
151 0 public object Intercept(IInvocation invocation, params object[] args)
152   {
153   ArrayList interceptorList = new ArrayList();
154   object ret = null;
155  
156   if (aspects != null)
157   {
158   foreach (IAspect aspect in aspects)
159   {
160   IPointcut pointcut = aspect.Pointcut;
161   if (pointcut == null || pointcut.IsApplied(invocation.Method))
162   {
163   interceptorList.Add(aspect.MethodInterceptor);
164   }
165   }
166   }
167   if (interceptorList.Count == 0)
168   {
169   ret = invocation.Proceed(args);
170   }
171   else
172   {
173   IMethodInterceptor[] interceptors = (IMethodInterceptor[])
174   interceptorList.ToArray(typeof(IMethodInterceptor));
175   IMethodInvocation mehotdInvocation =
176   new DynamicProxyMethodInvocation(
177   invocation.InvocationTarget, this.type, invocation, args, interceptors, parameters);
178   ret = interceptors[0].Invoke(mehotdInvocation);
179   }
180   return ret;
181   }
182  
183   #endregion
184   }
185   }
186