Clover.NET coverage report - Coverage

Coverage timestamp: Friday, May 20, 2005 9:17:00 PM

File Stats: LOC: 153   Methods: 4
NCLOC: 86 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Commands\IPreparedCommandProxy.cs 0.0 % 0.0 % 0.0 % 0.0 %
coverage
1  
2   #region Apache Notice
3   /*****************************************************************************
4   * $Header: $
5   * $Revision: $
6   * $Date: $
7   *
8   * iBATIS.NET Data Mapper
9   * Copyright (C) 2004 - Gilles Bayon
10   *
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   * http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   *
24   ********************************************************************************/
25   #endregion
26  
27   #region Using
28   using System;
29   using System.Data;
30   using System.Collections;
31   using System.Reflection;
32   using System.Xml.Serialization;
33   using System.Text;
34  
35   using Castle.DynamicProxy;
36  
37   using IBatisNet.Common;
38   using IBatisNet.Common.Utilities.Objects;
39  
40   using IBatisNet.Common.Exceptions;
41  
42   using log4net;
43   #endregion
44  
45   namespace IBatisNet.DataMapper.Commands
46   {
47   /// <summary>
48   /// Summary description for IPreparedCommandProxy.
49   /// </summary>
50   public class IPreparedCommandProxy : IInterceptor
51   {
52  
53   #region Fields
54   private IPreparedCommand _preparedCommand = null;
55   private static ArrayList _passthroughMethods = new ArrayList();
56   private static readonly ILog _logger = LogManager.GetLogger( "IBatisNet.DataMapper.Commands.IPreparedCommand" );
57  
58   #endregion
59  
60   #region Constructors
61  
62 0 static IPreparedCommandProxy()
63   {
64   _passthroughMethods.Add("GetType");
65   _passthroughMethods.Add("ToString");
66   }
67  
68   /// <summary>
69   /// Constructor for a connection proxy
70   /// </summary>
71   /// <param name="preparedCommand">The connection which been proxified.</param>
72 0 internal IPreparedCommandProxy(IPreparedCommand preparedCommand)
73   {
74   _preparedCommand = preparedCommand;
75   }
76   #endregion
77  
78   #region Methods
79  
80   /// <summary>
81   /// Static constructor
82   /// </summary>
83   /// <param name="preparedCommand">The connection which been proxified.</param>
84   /// <returns>A proxy</returns>
85 0 internal static IPreparedCommand NewInstance(IPreparedCommand preparedCommand)
86   {
87   object proxyIPreparedCommand = null;
88   IInterceptor handler = new IPreparedCommandProxy(preparedCommand);
89  
90   ProxyGenerator proxyGenerator = new ProxyGenerator();
91  
92   proxyIPreparedCommand = proxyGenerator.CreateProxy(typeof(IPreparedCommand), handler, preparedCommand);
93  
94   return (IPreparedCommand) proxyIPreparedCommand;
95   }
96   #endregion
97  
98   #region IInterceptor Members
99  
100   /// <summary>
101   ///
102   /// </summary>
103   /// <param name="invocation"></param>
104   /// <param name="arguments"></param>
105   /// <returns></returns>
106 0 public object Intercept(IInvocation invocation, params object[] arguments)
107   {
108   object returnValue = null;
109  
110   returnValue = invocation.Method.Invoke( _preparedCommand, arguments);
111  
112   if (invocation.Method.Name=="Create")
113   {
114   if (_logger.IsDebugEnabled)
115   {
116   IDbCommand command = (IDbCommand)returnValue;
117  
118   _logger.Debug("PreparedStatement : [" + command.CommandText + "]");
119   if (command.Parameters.Count>0)
120   {
121   StringBuilder valueList = new StringBuilder(); // Log info
122   StringBuilder typeList = new StringBuilder(); // Log info
123  
124   for ( int i = 0; i < command.Parameters.Count; ++i )
125   {
126   IDataParameter sqlParameter = (IDataParameter)command.Parameters[i];
127   if (sqlParameter.Value == System.DBNull.Value)
128   {
129   valueList.Append("null,");
130   typeList.Append("null,");
131   }
132   else
133   {
134   valueList.Append( sqlParameter.Value.ToString() );
135   valueList.Append( "," );
136   typeList.Append( sqlParameter.Value.GetType().ToString() );
137   typeList.Append( "," );
138   }
139   }
140  
141   _logger.Debug("Parameters: [" + valueList.ToString().Remove(valueList.ToString().Length-1,1) + "]");
142   _logger.Debug("Types: [" + typeList.ToString().Remove(typeList.ToString().Length-1,1) + "]");
143   }
144   }
145   }
146  
147   return returnValue;
148   }
149  
150   #endregion
151   }
152   }
153