You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/04/28 20:49:38 UTC

svn commit: r165174 - /incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs

Author: gbayon
Date: Thu Apr 28 11:49:37 2005
New Revision: 165174

URL: http://svn.apache.org/viewcvs?rev=165174&view=rev
Log:
-Fixed JIRA46

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs?rev=165174&r1=165173&r2=165174&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs Thu Apr 28 11:49:37 2005
@@ -96,6 +96,12 @@
 		private bool _useParameterPrefixInParameter = true;
 		[NonSerialized]
 		private bool _usePositionalParameters = false;
+		[NonSerialized]
+		private bool _templateConnectionIsICloneable = false;
+		[NonSerialized]
+		private bool _templateCommandIsICloneable = false;
+		[NonSerialized]
+		private bool _templateDataAdapterIsICloneable = false;
 		
 		private static readonly ILog _connectionLogger = LogManager.GetLogger("System.Data.IDbConnection");
 
@@ -424,6 +430,10 @@
 				// Get the CommandBuilder Type
 				_commandBuilderType = assembly.GetType(_commandBuilderClass, true);
 				_parameterDbType = assembly.GetType(_parameterDbTypeClass, true);
+
+				_templateConnectionIsICloneable = _templateConnection is ICloneable;
+				_templateCommandIsICloneable = _templateCommand is ICloneable;
+				_templateDataAdapterIsICloneable = _templateDataAdapter is ICloneable;
 			}
 			catch(Exception e)
 			{
@@ -447,8 +457,14 @@
 //			{
 //				connection = (IDbConnection)IDbConnectionProxy.NewInstance(connection, this);
 //			}
-
-			return (IDbConnection) ((ICloneable)_templateConnection).Clone();
+			if (_templateConnectionIsICloneable)
+			{
+				return (IDbConnection) ((ICloneable)_templateConnection).Clone();
+			}
+			else
+			{
+				return (IDbConnection) Activator.CreateInstance(_templateConnection.GetType());
+			}
 		}
 
 		/// <summary>
@@ -457,7 +473,14 @@
 		/// <returns>An 'IDbCommand' object.</returns>
 		public IDbCommand GetCommand()
 		{
-			return (IDbCommand) ((ICloneable)_templateCommand).Clone();
+			if (_templateCommandIsICloneable)
+			{
+				return (IDbCommand) ((ICloneable)_templateCommand).Clone();
+			}
+			else
+			{
+				return (IDbCommand) Activator.CreateInstance(_templateCommand.GetType());
+			}
 		}
 
 		/// <summary>
@@ -466,7 +489,14 @@
 		/// <returns>An 'IDbDataAdapter' object.</returns>
 		public IDbDataAdapter GetDataAdapter()
 		{
-			return (IDbDataAdapter) ((ICloneable)_templateDataAdapter).Clone();
+			if (_templateDataAdapterIsICloneable)
+			{
+				return (IDbDataAdapter) ((ICloneable)_templateDataAdapter).Clone();
+			}
+			else
+			{
+				return (IDbDataAdapter) Activator.CreateInstance(_templateDataAdapter.GetType());
+			}
 		}
 
 		/// <summary>