Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 92   Methods: 1
NCLOC: 59 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Aop\Interceptors\TraceInterceptor.cs 33.3% 70.4% 100.0% 64.7%
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.Text;
21   using System.Reflection;
22   using Seasar.Framework.Log;
23  
24   namespace Seasar.Framework.Aop.Interceptors
25   {
26   /// <summary>
27   /// 呼び出されたメソッドのトレースをログに出力するInterceptor
28   /// </summary>
29   public class TraceInterceptor : AbstractInterceptor
30   {
31   /// <summary>
32   /// ロガー
33   /// </summary>
34   private static Logger logger_ = Logger.GetLogger(typeof(TraceInterceptor));
35  
36   #region IMethodInterceptor クラス
37  
38   /// <summary>
39   /// メソッドがInterceptされる場合、このメソッドが呼び出されます
40   /// </summary>
41   /// <param name="invocation">IMethodInvocation</param>
42   /// <returns>Interceptされるメソッドの戻り値</returns>
43 8 public override object Invoke(IMethodInvocation invocation)
44   {
45 8 MethodBase mb = invocation.Method;
46 8 StringBuilder buf = new StringBuilder(100);
47 8 buf.Append(mb.DeclaringType.FullName);
48 8 buf.Append("#");
49 8 buf.Append(mb.Name);
50 8 buf.Append("(");
51 8 object[] args = invocation.Arguments;
52 8 if(args != null && args.Length > 0)
53   {
54 0 for(int i=0;i<args.Length;i++)
55   {
56   buf.Append(args[i]);
57   buf.Append(", ");
58   }
59 0 buf.Length = buf.Length - 2;
60   }
61 8 buf.Append(")");
62 8 logger_.Debug("BEGIN " + buf.ToString());
63 8 object ret = null;
64 8 Exception cause = null;
65 8 try
66   {
67 8 ret = invocation.Proceed();
68 8 buf.Append(" : ");
69 8 buf.Append(ret);
70   }
71   catch(Exception ex)
72   {
73 0 buf.Append(" Exception:");
74 0 buf.Append(ex);
75 0 cause = ex;
76   }
77 8 logger_.Debug("END " + buf.ToString());
78 8 if(cause == null)
79   {
80 8 return ret;
81   }
82   else
83   {
84 0 throw cause;
85   }
86   }
87  
88   #endregion
89  
90   }
91   }
92