Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 125   Methods: 6
NCLOC: 101 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\MethodUtil.cs 44.4% 48.7% 50.0% 47.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.Reflection;
21   using System.Text;
22   using Seasar.Framework.Exceptions;
23  
24   namespace Seasar.Framework.Util
25   {
26   public sealed class MethodUtil
27   {
28 0 private MethodUtil()
29   {
30   }
31  
32 50 public static object Invoke(MethodInfo method,object target,object[] args)
33   {
34 50 try
35   {
36 50 return method.Invoke(target,args);
37   }
38   catch(TargetInvocationException ex)
39   {
40 0 throw new InvocationTargetRuntimeException(method.DeclaringType,ex);
41   }
42   catch(TargetException ex)
43   {
44 0 throw new IllegalAccessRuntimeException(method.DeclaringType,ex);
45   }
46   catch(ArgumentException ex)
47   {
48 0 throw new IllegalAccessRuntimeException(method.DeclaringType,ex);
49   }
50   catch(TargetParameterCountException ex)
51   {
52 0 throw new IllegalAccessRuntimeException(method.DeclaringType,ex);
53   }
54   catch(MethodAccessException ex)
55   {
56 0 throw new IllegalAccessRuntimeException(method.DeclaringType,ex);
57   }
58   }
59  
60 2 public static string GetSignature(string methodName,Type[] argTypes)
61   {
62 2 StringBuilder buf = new StringBuilder(100);
63 2 buf.Append(methodName);
64 2 buf.Append("(");
65 2 if(argTypes != null)
66   {
67 1 for(int i = 0; i < argTypes.Length; ++i)
68   {
69 0 if(i > 0) buf.Append(", ");
70 0 buf.Append(argTypes[i].FullName);
71   }
72   }
73 2 buf.Append(")");
74 2 return buf.ToString();
75   }
76  
77  
78 3 public static string GetSignature(string methodName,object[] methodArgs)
79   {
80 3 StringBuilder buf = new StringBuilder(100);
81 3 buf.Append(methodName);
82 3 buf.Append("(");
83 3 if(methodArgs != null)
84   {
85 4 for(int i = 0; i < methodArgs.Length; ++i)
86   {
87 0 if(i > 0) buf.Append(", ");
88 1 if(methodArgs[i] != null)
89   {
90 1 buf.Append(methodArgs[i].GetType().FullName);
91   }
92   else
93   {
94 0 buf.Append("null");
95   }
96   }
97   }
98 3 buf.Append(")");
99 3 return buf.ToString();
100   }
101  
102 0 public static string[] GetParameterNames(MethodInfo mi)
103   {
104   ParameterInfo[] parameters = mi.GetParameters();
105   string[] argNames = new string[parameters.Length];
106   for(int i = 0; i < parameters.Length; ++i)
107   {
108   argNames[i] = parameters[i].Name;
109   }
110   return argNames;
111   }
112  
113 0 public static Type[] GetParameterTypes(MethodInfo mi)
114   {
115   ParameterInfo[] parameters = mi.GetParameters();
116   Type[] argTypes = new Type[parameters.Length];
117   for(int i = 0; i < parameters.Length; ++i)
118   {
119   argTypes[i] = parameters[i].ParameterType;
120   }
121   return argTypes;
122   }
123   }
124   }
125