Clover.NET coverage report - Coverage

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

File Stats: LOC: 142   Methods: 4
NCLOC: 76 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Logging\IDbConnectionProxy.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  
34   using Castle.DynamicProxy;
35  
36   using IBatisNet.Common;
37   using IBatisNet.Common.Utilities.Objects;
38  
39   using IBatisNet.Common.Exceptions;
40  
41   using log4net;
42   #endregion
43  
44   namespace IBatisNet.Common.Logging
45   {
46   /// <summary>
47   /// Summary description for IDbConnectionProxy.
48   /// </summary>
49   /// <remarks>Not used.</remarks>
50   public class IDbConnectionProxy : IInterceptor
51   {
52  
53   #region Fields
54   private string _connectionString = string.Empty;
55   private IDbConnection _connection = null;
56   private Provider _provider = null;
57   private static ArrayList _passthroughMethods = new ArrayList();
58   private static readonly ILog _logger = LogManager.GetLogger( "System.Data.IDbConnection" );
59  
60   #endregion
61  
62   #region Constructors
63  
64 0 static IDbConnectionProxy()
65   {
66   _passthroughMethods.Add("GetType");
67   _passthroughMethods.Add("ToString");
68   }
69  
70   /// <summary>
71   /// Constructor for a connection proxy
72   /// </summary>
73   /// <param name="connection">The connection which been proxified.</param>
74   /// <param name="provider">The provider used</param>
75 0 internal IDbConnectionProxy(IDbConnection connection, Provider provider)
76   {
77   _connection = connection;
78   _provider = provider;
79   }
80   #endregion
81  
82   #region Methods
83  
84   /// <summary>
85   /// Static constructor
86   /// </summary>
87   /// <param name="connection">The connection which been proxified.</param>
88   /// <param name="provider">The provider used</param>
89   /// <returns>A proxy</returns>
90 0 internal static IDbConnection NewInstance(IDbConnection connection, Provider provider)
91   {
92   object proxyConnection = null;
93   IInterceptor handler = new IDbConnectionProxy(connection, provider);
94  
95   ProxyGenerator proxyGenerator = new ProxyGenerator();
96  
97   proxyConnection = proxyGenerator.CreateProxy(typeof(IDbConnection), handler, connection);
98  
99   return (IDbConnection) proxyConnection;
100   }
101   #endregion
102  
103   #region IInterceptor Members
104  
105   /// <summary>
106   ///
107   /// </summary>
108   /// <param name="invocation"></param>
109   /// <param name="arguments"></param>
110   /// <returns></returns>
111 0 public object Intercept(IInvocation invocation, params object[] arguments)
112   {
113   object returnValue = null;
114  
115   if (invocation.Method.Name=="Open")
116   {
117   _connection.Open();
118   if (_logger.IsDebugEnabled)
119   {
120   _logger.Debug( string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _provider.Description) );
121   }
122   }
123   else if (invocation.Method.Name=="Close")
124   {
125   _connection.Close();
126   if (_logger.IsDebugEnabled)
127   {
128   _logger.Debug( string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _provider.Description) );
129   }
130   }
131   else //if ( !_passthroughMethods.Contains(invocation.Method.Name) )
132   {
133   returnValue = invocation.Method.Invoke( _connection, arguments);
134   }
135  
136   return returnValue;
137   }
138  
139   #endregion
140   }
141   }
142