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/05/08 18:20:33 UTC

svn commit: r169140 [2/2] - /incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Exceptions /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MySql /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/Oracle /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParamaterMapping /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Sun May  8 09:20:30 2005
@@ -696,6 +696,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "TypesHandler\CustomTypeHandler.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypesHandler\DateTimeTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -741,11 +746,36 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "TypesHandler\ITypeHandlerCallback.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypesHandler\ObjectTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "TypesHandler\ParameterSetter.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypesHandler\ParameterSetterImpl.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypesHandler\ResultGetter.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypesHandler\ResultGetterImpl.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "TypesHandler\SingleTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -762,6 +792,11 @@
                 />
                 <File
                     RelPath = "TypesHandler\TypeHandlerFactory.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "TypesHandler\UnknownTypeHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd Sun May  8 09:20:30 2005
@@ -518,6 +518,7 @@
 			<xs:attribute name="size" type="xs:string"/>
 			<xs:attribute name="scale" type="xs:string"/>
 			<xs:attribute name="precision" type="xs:string"/>
+			<xs:attribute name="typeHandler" type="xs:string"/>
 			<xs:attribute name="direction">
 				<xs:simpleType>
 					<xs:restriction base="xs:NMTOKEN">
@@ -570,6 +571,7 @@
 			<xs:attribute name="dbType" type="xs:string"/>
 			<xs:attribute name="columnIndex" type="xs:string"/>
 			<xs:attribute name="resultMapping" type="xs:string"/>
+			<xs:attribute name="typeHandler" type="xs:string"/>
 		</xs:complexType>
 	</xs:element>
 	<xs:element name="resultMap">

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BaseTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BaseTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BaseTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BaseTypeHandler.cs Sun May  8 09:20:30 2005
@@ -24,13 +24,14 @@
  ********************************************************************************/
 #endregion
 
+#region Using
+
 using System;
 using System.Data;
-using System.Collections;
-
+using IBatisNet.DataMapper.Configuration.ParameterMapping;
 using IBatisNet.DataMapper.Configuration.ResultMapping;
 
-using IBatisNet.Common.Utilities;
+#endregion 
 
 namespace IBatisNet.DataMapper.TypesHandler
 {
@@ -58,7 +59,7 @@
 				value = GetValueByIndex(mapping, dataReader);
 			}
 
-			bool wasNull = (value == System.DBNull.Value);
+			bool wasNull = (value == DBNull.Value);
 			if (wasNull)
 			{
 				if (mapping.HasNullValue) 
@@ -83,9 +84,28 @@
 
 		public abstract object GetDataBaseValue(object outputValue, Type parameterType );
 
-		public abstract bool IsEqualToNullValue(string nullValue, object realValue);
-
 		public abstract bool IsSimpleType();
+
+		/// <summary>
+		/// Performs processing on a value before it is used to set
+		/// the parameter of a IDbCommand.
+		/// </summary>
+		/// <param name="mapping">The mapping between data parameter and object property.</param>
+		/// <param name="dataParameter"></param>
+		/// <param name="parameterValue">The value to be set</param>
+		public virtual void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+		{
+			if (parameterValue!=null)
+			{
+				dataParameter.Value = parameterValue;
+			}
+			else
+			{
+				// When sending a null parameter value to the server,
+				// the user must specify DBNull, not null. 
+				dataParameter.Value = System.DBNull.Value;
+			}
+		}
 
 //		public abstract object GetDataParameter(ParameterProperty mapping, object source);
 	}

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BooleanTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BooleanTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BooleanTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/BooleanTypeHandler.cs Sun May  8 09:20:30 2005
@@ -84,19 +84,11 @@
 			return Convert.ToBoolean(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToBoolean(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{
 			return true;
 		}
 
-//		public abstract object GetDataParameter(ParameterProperty mapping, object source)
-//		{
-//			parameter.Value = 
-//		}
 	}
 }

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteArrayTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteArrayTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteArrayTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteArrayTypeHandler.cs Sun May  8 09:20:30 2005
@@ -122,11 +122,6 @@
 			throw new DataMapperException("NotSupportedException");
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return false;
-		}
-
 		public override bool IsSimpleType() 
 		{
 			return true;

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ByteTypeHandler.cs Sun May  8 09:20:30 2005
@@ -81,10 +81,6 @@
 			return Convert.ToByte(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToByte(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CharTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CharTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CharTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CharTypeHandler.cs Sun May  8 09:20:30 2005
@@ -81,10 +81,6 @@
 			return Convert.ToChar(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToChar(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CustomTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CustomTypeHandler.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CustomTypeHandler.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/CustomTypeHandler.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,89 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System;
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ParameterMapping;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// Custom type handler for adding a TypeHandlerCallback
+	/// </summary>
+	internal class CustomTypeHandler : BaseTypeHandler
+	{
+		private ITypeHandlerCallback _callback = null;
+
+		public CustomTypeHandler(ITypeHandlerCallback callback)
+		{
+			_callback = callback;
+		}
+
+		/// <summary>
+		/// Performs processing on a value before it is used to set
+		/// the parameter of a IDbCommand.
+		/// </summary>
+		/// <param name="mapping">The mapping between data parameter and object property.</param>
+		/// <param name="dataParameter"></param>
+		/// <param name="parameterValue">The value to be set</param>
+		public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+		{
+			IParameterSetter setter = new ParameterSetterImpl(dataParameter);
+			_callback.SetParameter(setter, parameterValue);
+		}
+
+		protected override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
+		{
+			IResultGetter getter = new ResultGetterImpl(dataReader, mapping.ColumnName);
+			return _callback.GetResult(getter);
+		}
+
+		protected override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
+		{
+			IResultGetter getter = new ResultGetterImpl(dataReader, mapping.ColumnIndex);
+			return _callback.GetResult(getter);		
+		}
+
+		protected override object GetNullValue(ResultProperty mapping)
+		{
+			return _callback.GetNullValue(mapping.NullValue);
+		}
+
+		public override object GetDataBaseValue(object outputValue, Type parameterType)
+		{
+			IResultGetter getter = new ResultGetterImpl(outputValue);
+			return _callback.GetResult(getter);	
+		}
+
+		public override bool IsSimpleType()
+		{
+			return false;
+		}
+	}
+}

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DateTimeTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DateTimeTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DateTimeTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DateTimeTypeHandler.cs Sun May  8 09:20:30 2005
@@ -80,10 +80,6 @@
 			return Convert.ToDateTime(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToDateTime(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DecimalTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DecimalTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DecimalTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DecimalTypeHandler.cs Sun May  8 09:20:30 2005
@@ -83,10 +83,6 @@
 			return Convert.ToDecimal(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToDecimal(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DoubleTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DoubleTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DoubleTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/DoubleTypeHandler.cs Sun May  8 09:20:30 2005
@@ -80,10 +80,6 @@
 			return Convert.ToDouble(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToDouble(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/EnumTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/EnumTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/EnumTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/EnumTypeHandler.cs Sun May  8 09:20:30 2005
@@ -82,10 +82,6 @@
 			return Enum.Parse(parameterType, outputValue.ToString());
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, object realValue) 
-		{
-			return Enum.Parse(realValue.GetType(), nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/GuidTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/GuidTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/GuidTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/GuidTypeHandler.cs Sun May  8 09:20:30 2005
@@ -80,11 +80,6 @@
 			return new Guid(outputValue.ToString());
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, object realValue) 
-		{
-			Guid guid = new Guid(nullValue);
-			return guid.Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandler.cs Sun May  8 09:20:30 2005
@@ -24,12 +24,13 @@
  ********************************************************************************/
 #endregion
 
+#region Using
+
 using System;
 using System.Data;
-
-using IBatisNet.DataMapper.Configuration.ResultMapping;
 using IBatisNet.DataMapper.Configuration.ParameterMapping;
-using IBatisNet.DataMapper;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+#endregion 
 
 namespace IBatisNet.DataMapper.TypesHandler
 {
@@ -49,32 +50,25 @@
 		/// <summary>
 		/// 
 		/// </summary>
-		/// <param name="nullValue"></param>
-		/// <param name="realValue"></param>
-		/// <returns></returns>
-		bool IsEqualToNullValue(string nullValue, object realValue);
-
-		/// <summary>
-		/// 
-		/// </summary>
 		/// <returns></returns>
 		bool IsSimpleType();
 
 		/// <summary>
-		/// 
+		/// Retrieve ouput database value of an output parameter
 		/// </summary>
-		/// <param name="outputValue"></param>
-		/// <param name="parameterType"></param>
+		/// <param name="outputValue">ouput database value</param>
+		/// <param name="parameterType">type used in EnumTypeHandler</param>
 		/// <returns></returns>
 		object GetDataBaseValue(object outputValue, Type parameterType);
 
-//		/// <summary>
-//		/// Get value to set a data parameter. 
-//		/// </summary>
-//		/// <param name="mapping">The mapping between data parameter and object property.</param>
-//		/// <param name="source">The object from the value will be read.</param>
-//		/// <returns>A value to set.</returns>
-//		object GetDataParameter(ParameterProperty mapping, object source);
+		/// <summary>
+		/// Performs processing on a value before it is used to set
+		/// the parameter of a IDbCommand.
+		/// </summary>
+		/// <param name="mapping">The mapping between data parameter and object property.</param>
+		/// <param name="dataParameter"></param>
+		/// <param name="parameterValue">The value to be set</param>
+		void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue);
 
 	}
 }

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandlerCallback.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandlerCallback.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandlerCallback.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ITypeHandlerCallback.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,75 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ParameterMapping;
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// A simple interface for implementing custom type handlers.
+	/// <p/>
+	/// Using this interface, you can implement a type handler that
+	/// will perform customized processing before parameters are set
+	/// on a IDbCommand and after values are retrieved from
+	/// a IDataReader.  Using a custom type handler you can extend
+	/// the framework to handle types that are not supported, or
+	/// handle supported types in a different way.  For example,
+	/// you might use a custom type handler to implement proprietary
+	/// BLOB support (e.g. Oracle), or you might use it to handle
+	/// booleans using "Y" and "N" instead of the more typical 0/1.
+	/// </summary>
+	public interface ITypeHandlerCallback
+	{
+		/// <summary>
+		/// Performs processing on a value before it is used to set
+		/// the parameter of a IDbCommand.
+		/// </summary>
+		/// <param name="setter">The interface for setting the value on the IDbCommand.</param>
+		/// <param name="parameter">The value to be set</param>
+		void SetParameter(IParameterSetter setter, object parameter);
+
+
+		/// <summary>
+		/// Performs processing on a value before after it has been retrieved
+		/// from a IDataReader.
+		/// </summary>
+		/// <param name="getter">The interface for getting the value from the IDataReader.</param>
+		/// <returns>The processed value.</returns>
+		object GetResult(IResultGetter getter);
+
+		/// <summary>
+		///  Converts the string to the type that this handler deals with
+		/// </summary>
+		/// <param name="nullValue">the String value</param>
+		/// <returns>the converted value</returns>
+		object GetNullValue(string nullValue);
+	}
+}

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int16TypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int16TypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int16TypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int16TypeHandler.cs Sun May  8 09:20:30 2005
@@ -83,10 +83,6 @@
 			return Convert.ToInt16(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToInt16(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int32TypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int32TypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int32TypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int32TypeHandler.cs Sun May  8 09:20:30 2005
@@ -24,16 +24,19 @@
  ********************************************************************************/
 #endregion
 
+#region Using
+
 using System;
 using System.Data;
-using System.Globalization;
-
+using IBatisNet.DataMapper.Configuration.ParameterMapping;
 using IBatisNet.DataMapper.Configuration.ResultMapping;
+#endregion 
+
 
 namespace IBatisNet.DataMapper.TypesHandler
 {
 	/// <summary>
-	/// Description résumée de Int32TypeHandler.
+	/// Summary description for Int32TypeHandler.
 	/// </summary>
 	internal class Int32TypeHandler : BaseTypeHandler
 	{
@@ -50,7 +53,7 @@
 
 			if (dataReader.IsDBNull(index) == true)
 			{
-				return System.DBNull.Value;
+				return DBNull.Value;
 			}
 			else
 			{
@@ -63,7 +66,7 @@
 		{
 			if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
 			{
-				return System.DBNull.Value;
+				return DBNull.Value;
 			}
 			else
 			{
@@ -82,19 +85,11 @@
 			return Convert.ToInt32(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToInt32(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{
 			return true;
 		}
 
-//		public void SetParameter(ParameterProperty mapping, PreparedStatement preparedStatement, int index, object obj) 
-//		{
-//			ps.setInt(index, ((Integer) value).intValue());
-//		}
 	}
 }

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int64TypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int64TypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int64TypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/Int64TypeHandler.cs Sun May  8 09:20:30 2005
@@ -82,10 +82,6 @@
 			return Convert.ToInt64(outputValue);
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToInt64(nullValue).Equals(realValue);
-		}
 
 		public override bool IsSimpleType() 
 		{

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ObjectTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ObjectTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ObjectTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ObjectTypeHandler.cs Sun May  8 09:20:30 2005
@@ -80,10 +80,6 @@
 			return outputValue;
 		}
 
-		public override bool IsEqualToNullValue(string nullValue, object realValue) 
-		{
-			return (realValue == null);
-		}
 
 		public override bool IsSimpleType() 
 		{

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetter.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetter.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetter.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetter.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,58 @@
+using System.Data;
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// Allows parameters to be set on the underlying prepared IDbCommand.
+	/// TypeHandlerCallback implementations use this interface to
+	/// process values before they are set on the IDbCommand.
+	/// </summary>
+	/// <remarks>
+	/// There is no need to implement this.  The implementation
+	/// will be passed into the TypeHandlerCallback automatically.
+	/// </remarks>
+	public interface IParameterSetter
+	{
+
+		/// <summary>
+		/// Returns the underlying IDataParameter
+		/// </summary>
+		IDataParameter DataParameter { get; }
+
+		/// <summary>
+		/// Get the parameter value
+		/// </summary>
+		object Value { set; }
+	}
+}

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetterImpl.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetterImpl.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetterImpl.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ParameterSetterImpl.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,84 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System.Data;
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// A ParameterSetter implementation
+	/// </summary>
+	public class ParameterSetterImpl  : IParameterSetter	
+	{
+		#region Fields
+
+		private IDataParameter _dataParameter = null;
+
+		#endregion 
+
+		#region Constructor
+
+		/// <summary>
+		/// Default Constructor
+		/// </summary>
+		/// <param name="dataParameter"></param>
+		public ParameterSetterImpl(IDataParameter dataParameter) 
+		{
+			_dataParameter = dataParameter;
+		}
+		#endregion 
+
+		#region IParameterSetter members
+
+		/// <summary>
+		/// Returns the underlying DataParameter
+		/// </summary>
+		public IDataParameter DataParameter
+		{
+			get
+			{
+				return _dataParameter;
+			}
+		}
+
+		/// <summary>
+		/// Set the parameter value
+		/// </summary>
+		public object Value
+		{
+			set
+			{
+				_dataParameter.Value = value;
+			}
+		}
+
+		#endregion
+	}
+}

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetter.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetter.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetter.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetter.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,58 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System.Data;
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// Allows values to be retrieved from the underlying IDataReader.
+	/// TypeHandlerCallback implementations use this interface to
+	/// get values that they can subsequently manipulate before
+	/// having them returned.  																																																														   * or index with these methods.
+	/// </summary>
+	/// <remarks>
+	/// There is no need to implement this.  The implementation
+	/// will be passed into the TypeHandlerCallback automatically.
+	/// </remarks>
+	public interface IResultGetter
+	{
+
+		/// <summary>
+		/// Returns the underlying IDataReader
+		/// </summary>
+		IDataReader DataReader { get; }
+
+		/// <summary>
+		/// Get the parameter value
+		/// </summary>
+		object Value { get; }
+	}
+}

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetterImpl.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetterImpl.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetterImpl.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/ResultGetterImpl.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,124 @@
+
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System.Data;
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	/// Description résumée de ResultGetterImpl.
+	/// </summary>
+	public class ResultGetterImpl : IResultGetter
+	{
+
+		#region Fields
+
+		private int _columnIndex = int.MinValue;
+		private string _columnName = string.Empty;
+		private object _outputValue = null;
+
+		private IDataReader _dataReader = null;
+		#endregion 
+
+		#region Constructors
+
+		/// <summary>
+		/// Creates an instance for a IDataReader and column index
+		/// </summary>
+		/// <param name="dataReader">The dataReader</param>
+		/// <param name="columnIndex">the column index</param>
+		public ResultGetterImpl(IDataReader dataReader, int columnIndex)
+		{
+			_columnIndex = columnIndex;
+			_dataReader = dataReader;
+		}
+
+		/// <summary>
+		/// Creates an instance for a IDataReader and column name
+		/// </summary>
+		/// <param name="dataReader">The dataReader</param>
+		/// <param name="columnName">the column name</param>
+		public ResultGetterImpl(IDataReader dataReader, string columnName)
+		{
+			_columnName= columnName;
+			_dataReader = dataReader;
+		}
+
+		/// <summary>
+		/// Creates an instance for an output parameter
+		/// </summary>
+		/// <param name="outputValue">value of an output parameter (store procedure)</param>
+		public ResultGetterImpl(object outputValue)
+		{
+			_outputValue = outputValue;
+		}
+		#endregion 
+
+		#region IResultGetter members
+
+		/// <summary>
+		/// Returns the underlying IDataReader
+		/// </summary>
+		/// <remarks>Null for an output parameter</remarks>
+		public IDataReader DataReader
+		{
+			get
+			{
+				return _dataReader;
+			}
+		}
+
+		/// <summary>
+		/// Get the parameter value
+		/// </summary>
+		public object Value
+		{
+			get
+			{
+				if (_columnName.Length >0)
+				{
+					int index = _dataReader.GetOrdinal(_columnName);
+					return _dataReader.GetValue(index);
+				}
+				else if (_columnIndex>=0)
+				{
+					return _dataReader.GetValue(_columnIndex);
+				}
+				else
+				{
+					return _outputValue;
+				}
+			}
+		}
+		#endregion 
+
+	}
+}

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/SingleTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/SingleTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/SingleTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/SingleTypeHandler.cs Sun May  8 09:20:30 2005
@@ -91,16 +91,6 @@
 			return Convert.ToSingle(outputValue);;
 		}
 
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="nullValue"></param>
-		/// <param name="realValue"></param>
-		/// <returns></returns>
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			return Convert.ToSingle(nullValue).Equals(realValue);
-		}
 
 		/// <summary>
 		/// 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/StringTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/StringTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/StringTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/StringTypeHandler.cs Sun May  8 09:20:30 2005
@@ -91,16 +91,6 @@
 			return Convert.ToString(outputValue);;
 		}
 
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="nullValue"></param>
-		/// <param name="realValue"></param>
-		/// <returns></returns>
-		public override bool IsEqualToNullValue(string nullValue, object realValue) 
-		{
-			return Convert.ToString(nullValue).Equals(realValue);
-		}
 
 		/// <summary>
 		/// 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TimeSpanTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TimeSpanTypeHandler.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TimeSpanTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TimeSpanTypeHandler.cs Sun May  8 09:20:30 2005
@@ -79,18 +79,6 @@
 			return  new TimeSpan(Convert.ToInt64(outputValue));
 		}
 
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="nullValue"></param>
-		/// <param name="realValue"></param>
-		/// <returns></returns>
-		public override bool IsEqualToNullValue(string nullValue, Object realValue) 
-		{
-			TimeSpan stamp = new TimeSpan(Convert.ToInt64(nullValue));
-
-			return stamp.Equals(realValue);
-		}
 
 		/// <summary>
 		/// 

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TypeHandlerFactory.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TypeHandlerFactory.cs?rev=169140&r1=169139&r2=169140&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TypeHandlerFactory.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/TypeHandlerFactory.cs Sun May  8 09:20:30 2005
@@ -24,18 +24,28 @@
  ********************************************************************************/
 #endregion
 
+#region Using
+
 using System;
 using System.Collections.Specialized;
 
+#endregion 
+
 namespace IBatisNet.DataMapper.TypesHandler
 {
 	/// <summary>
-	/// Description résumée de TypeHandlerFactory.
+	/// Not much of a suprise, this is a factory class for TypeHandler objects.
 	/// </summary>
 	internal class TypeHandlerFactory
 	{
+
+		#region Fields
+
 		private static readonly HybridDictionary _typeHandlerMap = new HybridDictionary();
 
+		#endregion 
+
+		#region Constructor
 
 		/// <summary>
 		/// Constructor
@@ -94,6 +104,7 @@
 
 		}
 
+		#endregion 
 
 		#region Methods
 
@@ -115,14 +126,24 @@
 		}
 
 		/// <summary>
-		/// 
+		/// Get a TypeHandler for a type
 		/// </summary>
 		/// <param name="type"></param>
 		/// <param name="dbType"></param>
 		/// <returns></returns>
 		public static ITypeHandler GetTypeHandler(Type type, string dbType) 
 		{
-			return (ITypeHandler) GetTypeHandler(type);
+			return GetTypeHandler(type);
+		}
+
+
+		/// <summary>
+		/// When in doubt, get the "unknown" type handler
+		/// </summary>
+		/// <returns>if I told you, it would not be unknown, would it?</returns>
+		public static ITypeHandler GetUnkownTypeHandler() 
+		{
+			return new UnknownTypeHandler();
 		}
 
 		/// <summary>

Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/UnknownTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/UnknownTypeHandler.cs?rev=169140&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/UnknownTypeHandler.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypesHandler/UnknownTypeHandler.cs Sun May  8 09:20:30 2005
@@ -0,0 +1,107 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System;
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ParameterMapping;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+
+#endregion 
+
+namespace IBatisNet.DataMapper.TypesHandler
+{
+	/// <summary>
+	///  Implementation of TypeHandler for dealing with unknown types
+	/// </summary>
+	internal class UnknownTypeHandler : BaseTypeHandler
+	{
+
+		/// <summary>
+		/// Performs processing on a value before it is used to set
+		/// the parameter of a IDbCommand.
+		/// </summary>
+		/// <param name="mapping">The mapping between data parameter and object property.</param>
+		/// <param name="dataParameter"></param>
+		/// <param name="parameterValue">The value to be set</param>
+		public override void SetParameter(ParameterProperty mapping, IDataParameter dataParameter, object parameterValue)
+		{
+			if (parameterValue!=null)
+			{
+				ITypeHandler handler = TypeHandlerFactory.GetTypeHandler( parameterValue.GetType() );
+				handler.SetParameter(mapping, dataParameter, parameterValue);
+			}
+			else
+			{
+				// When sending a null parameter value to the server,
+				// the user must specify DBNull, not null. 
+				dataParameter.Value = System.DBNull.Value;
+			}
+		}
+
+		protected override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
+		{
+			int index = dataReader.GetOrdinal(mapping.ColumnName);
+
+			if (dataReader.IsDBNull(index) == true)
+			{
+				return System.DBNull.Value;
+			}
+			else
+			{
+				return dataReader.GetValue(index);
+			}		
+		}
+
+		protected override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
+		{
+			if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
+			{
+				return System.DBNull.Value;
+			}
+			else
+			{
+				return dataReader.GetValue(mapping.ColumnIndex);
+			}		
+		}
+
+		protected override object GetNullValue(ResultProperty mapping)
+		{
+			throw new NotImplementedException();
+		}
+
+		public override object GetDataBaseValue(object outputValue, Type parameterType)
+		{
+			return outputValue;
+		}
+
+
+		public override bool IsSimpleType()
+		{
+			throw new NotImplementedException();
+		}
+	}
+}