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 2006/05/20 23:56:37 UTC

svn commit: r408099 [1/2] - in /ibatis/trunk/cs/mapper: IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ IBatisNet.Common/ IBatisNet.Common/Utilities/ IBatisNet.Common/Utilities/Objects/Members/ IBatisNet.Common/Utilities/TypesResolver/ IBatisNet.Dat...

Author: gbayon
Date: Sat May 20 14:56:36 2006
New Revision: 408099

URL: http://svn.apache.org/viewvc?rev=408099&view=rev
Log:
Fix IBATISNET-158 
+ refactoring
+ fix for DBHelperParameterCache in .NET 1.1

Added:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/ITypeResolver.cs
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/DbProvider.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/BaseAccessor.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/CachedTypeResolver.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeAliasResolver.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ArgumentProperty.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs Sat May 20 14:56:36 2006
@@ -96,6 +96,26 @@
 
         #endregion
 
+#if dotnet2
+
+        private T GetDefault<T>()
+        {
+            T frm = default(T);
+            return frm;
+        }
+
+        /// <summary>
+        /// Test Default value.
+        /// </summary>
+        [Test]
+        public void TestDefault()
+        {
+            Console.WriteLine("DateTime : " + GetDefault<DateTime>());
+            Console.WriteLine("TimeSpan : " + GetDefault<TimeSpan>());
+            Console.WriteLine("Guid : " + GetDefault<Guid>());
+            Console.WriteLine("Decimal : " + GetDefault<Decimal>());
+        }
+#endif
         /// <summary>
         /// Test setting null on integer public field.
         /// </summary>

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs Sat May 20 14:56:36 2006
@@ -1,7 +1,12 @@
 using System;
 using System.Text;
+using System.Collections.Generic;
+using System.Collections;
+
+using IBatisNet.Common.Test.Domain;
 using IBatisNet.Common.Utilities.TypesResolver;
 using NUnit.Framework;
+using IBatisNet.Common.Utilities;
 
 namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities
 {
@@ -16,9 +21,7 @@
         {
             Type nullableType = typeof(bool?);
 
-            TypeResolver resolver = new TypeResolver();
-
-            Type nullableBooleanType = resolver.Resolve(nullableType.FullName);
+            Type nullableBooleanType = TypeUtils.ResolveType(nullableType.FullName);
 
             Assert.IsNotNull(nullableBooleanType);
         }
@@ -31,11 +34,35 @@
         {
             Type nullableType = typeof(bool?);
 
-            TypeResolver resolver = new TypeResolver();
-
-            Type nullableBooleanType = resolver.Resolve(nullableType.AssemblyQualifiedName);
+            Type nullableBooleanType = TypeUtils.ResolveType(nullableType.AssemblyQualifiedName);
 
             Assert.IsNotNull(nullableBooleanType);
+        }
+
+        /// <summary>
+        /// Test generic list resolver
+        /// </summary>
+        [Test]
+        public void TestGeneicListType()
+        {
+            IList<Account> list = new List<Account>();
+            string assemblyQualifiedName = list.GetType().AssemblyQualifiedName;
+            Type listType = TypeUtils.ResolveType(assemblyQualifiedName);
+
+            Assert.IsNotNull(listType);
+        }
+
+        /// <summary>
+        /// Test generic dictionary resolver
+        /// </summary>
+        [Test]
+        public void TestGenericDictionaryType()
+        {
+            IDictionary<string, int> dico = new Dictionary<string, int>();
+            string assemblyQualifiedName = dico.GetType().AssemblyQualifiedName;
+            Type listType = TypeUtils.ResolveType(assemblyQualifiedName);
+
+            Assert.IsNotNull(listType);
         }
     }
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/DbProvider.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/DbProvider.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/DbProvider.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/DbProvider.cs Sat May 20 14:56:36 2006
@@ -31,7 +31,7 @@
 using System.Reflection;
 using System.Xml.Serialization;
 using IBatisNet.Common.Exceptions;
-using IBatisNet.Common.Utilities.TypesResolver;
+using IBatisNet.Common.Utilities;
 
 #endregion
 
@@ -469,7 +469,6 @@
 		{
 			Assembly assembly = null;
 			Type type = null;
-			CachedTypeResolver cachedTypeResolver = new CachedTypeResolver();
 
 			try
 			{
@@ -489,7 +488,7 @@
 				_commandBuilderType = assembly.GetType(_commandBuilderClass, true);
 				if (_parameterDbTypeClass.IndexOf(',')>0)
 				{
-					_parameterDbType = cachedTypeResolver.Resolve(_parameterDbTypeClass);
+                    _parameterDbType = TypeUtils.ResolveType(_parameterDbTypeClass);
 				}
 				else
 				{

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj Sat May 20 14:56:36 2006
@@ -253,12 +253,14 @@
     <Compile Include="Utilities\TypesResolver\CachedTypeResolver.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Utilities\TypesResolver\ITypeResolver.cs" />
     <Compile Include="Utilities\TypesResolver\TypeAliasResolver.cs">
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Utilities\TypesResolver\TypeResolver.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Utilities\TypeUtils.cs" />
     <Compile Include="Xml\NodeUtils.cs">
       <SubType>Code</SubType>
     </Compile>

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Sat May 20 14:56:36 2006
@@ -300,6 +300,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Utilities\TypeUtils.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Utilities\Objects\ActivatorFactory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -461,6 +466,11 @@
                 />
                 <File
                     RelPath = "Utilities\TypesResolver\CachedTypeResolver.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Utilities\TypesResolver\ITypeResolver.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs Sat May 20 14:56:36 2006
@@ -59,9 +59,7 @@
 		private static IDataParameter[] DiscoverSpParameterSet(IDalSession session, string spName, bool includeReturnValueParameter)
 		{
 			return InternalDiscoverSpParameterSet(
-                session.DataSource.DbProvider, 
-                session.Connection, 
-                session.Transaction,
+                session,
                 spName, 
                 includeReturnValueParameter);	
 		}
@@ -70,43 +68,46 @@
         /// <summary>
         /// Discover at run time the appropriate set of Parameters for a stored procedure
         /// </summary>
-        /// <param name="provider">The provider.</param>
-        /// <param name="connection">A valid open <see cref="IDbConnection"/>.</param>
-        /// <param name="transaction">A <see cref="IDbTransaction"/>.</param>
-        /// <param name="spName">Name of the stored procedure.</param>
+		/// <param name="session">An IDalSession object</param>
+		/// <param name="spName">Name of the stored procedure.</param>
         /// <param name="includeReturnValueParameter">if set to <c>true</c> [include return value parameter].</param>
         /// <returns>The stored procedure parameters.</returns>
-		private static IDataParameter[] InternalDiscoverSpParameterSet(IDbProvider provider,
-			IDbConnection connection, IDbTransaction transaction, string spName, 
+		private static IDataParameter[] InternalDiscoverSpParameterSet(IDalSession session, string spName, 
             bool includeReturnValueParameter)
 		{
-			using (IDbCommand cmd = connection.CreateCommand())
+#if !dotnet2
+			using (IDbConnection connection = session.DataSource.DbProvider.CreateConnection())
 			{
-                if (transaction != null)
-                {
-                    cmd.Transaction = transaction;
-                }
+				connection.ConnectionString = session.DataSource.ConnectionString;
+				connection.Open();
+				using (IDbCommand cmd = connection.CreateCommand())
+				{
 				cmd.CommandType = CommandType.StoredProcedure;
-				cmd.CommandText = spName;
-
-				DeriveParameters(provider, cmd);
-
-				if (cmd.Parameters.Count > 0) {
-					IDataParameter firstParameter = (IDataParameter)cmd.Parameters[0];
-					if (firstParameter.Direction == ParameterDirection.ReturnValue) {
-						if (!includeReturnValueParameter) {
-							cmd.Parameters.RemoveAt(0);
-						}
-					}	
+#else
+				using (IDbCommand cmd = session.CreateCommand(CommandType.StoredProcedure))
+				{
+#endif
+					cmd.CommandText = spName;
+
+					DeriveParameters(session.DataSource.DbProvider, cmd);
+
+					if (cmd.Parameters.Count > 0) {
+						IDataParameter firstParameter = (IDataParameter)cmd.Parameters[0];
+						if (firstParameter.Direction == ParameterDirection.ReturnValue) {
+							if (!includeReturnValueParameter) {
+								cmd.Parameters.RemoveAt(0);
+							}
+						}	
+					}
+
+
+					IDataParameter[] discoveredParameters = new IDataParameter[cmd.Parameters.Count];
+					cmd.Parameters.CopyTo(discoveredParameters, 0);
+					return discoveredParameters;
 				}
-
-
-				IDataParameter[] discoveredParameters = new IDataParameter[cmd.Parameters.Count];
-
-				cmd.Parameters.CopyTo(discoveredParameters, 0);
-
-				return discoveredParameters;
+#if !dotnet2
 			}
+#endif
 		}
 		
 		private static void DeriveParameters(IDbProvider provider, IDbCommand command)

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/BaseAccessor.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/BaseAccessor.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/BaseAccessor.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/BaseAccessor.cs Sat May 20 14:56:36 2006
@@ -97,6 +97,11 @@
                 }
                 else
                 {
+                    //DateTime : 01/01/0001 00:00:00
+                    //TimeSpan : 00:00:00
+                    //Guid : 00000000-0000-0000-0000-000000000000
+                    //Decimal : 0
+
                     if (type == typeof(DateTime)) { return DateTime.MinValue; }
                     if (type == typeof(Decimal)) { return 0m; }
                     if (type == typeof(Guid)) { return Guid.Empty; }

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs Sat May 20 14:56:36 2006
@@ -1,12 +1,12 @@
 
 #region Apache Notice
 /*****************************************************************************
- * $Header: $
- * $Revision: $
- * $Date$
+ * $Revision$
+ * $LastChangedDate$
+ * $LastChangedBy$
  * 
  * iBATIS.NET Data Mapper
- * Copyright (C) 2004 - Gilles Bayon
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
  *  
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,7 +56,7 @@
 		#region Fields
 		private static string _applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
 		private static string _baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
-		private static CachedTypeResolver _cachedTypeResolver = null;
+        //private static CachedTypeResolver _cachedTypeResolver = null;
 
 		private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
 
@@ -91,7 +91,7 @@
 		#region Constructor (s) / Destructor
 		static Resources()
 		{
-			_cachedTypeResolver = new CachedTypeResolver();
+            //_cachedTypeResolver = new CachedTypeResolver();
 		}
 		#endregion
 
@@ -503,12 +503,22 @@
 
 
 		/// <summary>
-		/// Find a type by his class name
+        /// Resolves the supplied type name into a <see cref="System.Type"/> instance.
 		/// </summary>
-		/// <param name="className">The className ot the type to find.</param>
-		public static Type TypeForName(string className)
+        /// <param name="typeName">
+        /// The (possibly partially assembly qualified) name of a <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the type cannot be resolved.
+        /// </exception>
+        [Obsolete("Use IBatisNet.Common.Utilities.TypeUtils")]
+		public static Type TypeForName(string typeName)
 		{
-			return _cachedTypeResolver.Resolve(className);
+			return TypeUtils.ResolveType(typeName);
+                //_cachedTypeResolver.Resolve(className);
 		}
 
 		#endregion

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs?rev=408099&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs Sat May 20 14:56:36 2006
@@ -0,0 +1,150 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-03-22 22:39:21 +0100 (mer., 22 mars 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *  
+ * 
+ * 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
+
+using System;
+
+using IBatisNet.Common.Utilities.TypesResolver;
+
+namespace IBatisNet.Common.Utilities
+{
+    /// <summary>
+    ///  Helper methods with regard to type.
+    /// </summary>
+    /// <remarks>
+    /// <p>
+    /// Mainly for internal use within the framework.
+    /// </p>
+    /// </remarks>
+    public sealed class TypeUtils
+    {
+        #region Fields
+
+        private static readonly ITypeResolver _internalTypeResolver = new CachedTypeResolver(new TypeResolver());
+
+        #endregion
+
+        #region Constructor (s) / Destructor
+
+		/// <summary>
+        /// Creates a new instance of the <see cref="IBatisNet.Common.Utilities.TypeUtils"/> class.
+		/// </summary>
+		/// <remarks>
+		/// <p>
+		/// This is a utility class, and as such exposes no public constructors.
+		/// </p>
+		/// </remarks>
+        private TypeUtils()
+		{
+		}
+
+		// CLOVER:ON
+
+		#endregion
+
+        /// <summary>
+        /// Resolves the supplied type name into a <see cref="System.Type"/>
+        /// instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The (possibly partially assembly qualified) name of a
+        /// <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the type cannot be resolved.
+        /// </exception>
+        public static Type ResolveType(string typeName)
+        {
+            Type type = TypeRegistry.ResolveType(typeName);
+            if (type == null)
+            {
+                type = _internalTypeResolver.Resolve(typeName);
+            }
+            return type;
+        }
+
+        /// <summary>
+        /// Instantiate a 'Primitive' Type.
+        /// </summary>
+        /// <param name="typeCode">a typeCode.</param>
+        /// <returns>An object.</returns>
+        public static object InstantiatePrimitiveType(TypeCode typeCode)
+        {
+            object resultObject = null;
+
+            switch (typeCode)
+            {
+                case TypeCode.Boolean:
+                    resultObject = new Boolean();
+                    break;
+                case TypeCode.Byte:
+                    resultObject = new Byte();
+                    break;
+                case TypeCode.Char:
+                    resultObject = new Char();
+                    break;
+                case TypeCode.DateTime:
+                    resultObject = new DateTime();
+                    break;
+                case TypeCode.Decimal:
+                    resultObject = new Decimal();
+                    break;
+                case TypeCode.Double:
+                    resultObject = new Double();
+                    break;
+                case TypeCode.Int16:
+                    resultObject = new Int16();
+                    break;
+                case TypeCode.Int32:
+                    resultObject = new Int32();
+                    break;
+                case TypeCode.Int64:
+                    resultObject = new Int64();
+                    break;
+                case TypeCode.SByte:
+                    resultObject = new SByte();
+                    break;
+                case TypeCode.Single:
+                    resultObject = new Single();
+                    break;
+                case TypeCode.String:
+                    resultObject = "";
+                    break;
+                case TypeCode.UInt16:
+                    resultObject = new UInt16();
+                    break;
+                case TypeCode.UInt32:
+                    resultObject = new UInt32();
+                    break;
+                case TypeCode.UInt64:
+                    resultObject = new UInt64();
+                    break;
+            }
+            return resultObject;
+        }
+    }
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/CachedTypeResolver.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/CachedTypeResolver.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/CachedTypeResolver.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/CachedTypeResolver.cs Sat May 20 14:56:36 2006
@@ -1,12 +1,13 @@
-
 #region Apache Notice
 /*****************************************************************************
- * $Header: $
- * $Revision: $
- * $Date$
+ * $Revision$
+ * $LastChangedDate$
+ * $LastChangedBy$
  * 
- * Copyright 2004 the original author or authors.
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
  *  
+ * 
  * 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
@@ -23,7 +24,7 @@
 #endregion
 
 #region Remarks
-// Code from Spring.NET
+// Inpspired from Spring.NET
 #endregion
 
 #region Imports
@@ -36,60 +37,87 @@
 
 namespace IBatisNet.Common.Utilities.TypesResolver
 {
-	/// <summary>
-	/// Summary description for CachedTypeResolver.
-	/// </summary>
-	public class CachedTypeResolver: TypeResolver
-	{
-		#region Constructor (s) / Destructor
-		/// <summary>
-		/// Creates a new instance of the CachedTypeResolver class.
-		/// </summary>
-		public CachedTypeResolver () {}
-		#endregion
-
-		#region Properties
-		/// <summary>
-		/// The cache, mapping type names against a <see cref="System.Type"/>
-		/// instance.
-		/// </summary>
-		private IDictionary TypeCache 
-		{
-			get 
-			{
-				return typeCache;
-			}
-		}
-		#endregion
-
-		#region Methods
-		/// <summary>
-		/// Resolves the supplied type name into a <see cref="System.Type"/>
-		/// instance.
-		/// </summary>
-		/// <param name="typeName">
-		/// The (possibly partially assembly qualified) name of a <see cref="System.Type"/>.
-		/// </param>
-		/// <returns>
-		/// A resolved <see cref="System.Type"/> instance.
-		/// </returns>
-		/// <exception cref="System.TypeLoadException">
-		/// If the type could not be resolved.
-		/// </exception>
-		public override Type Resolve (string typeName)
-		{
-			Type type = TypeCache [typeName] as Type;
-			if (type == null)
-			{
-				type = base.Resolve (typeName);
-				TypeCache [typeName] = type;
-			}
-			return type;
-		}
-		#endregion
-
-		#region Fields
-		private IDictionary typeCache = new HybridDictionary ();
-		#endregion
-	}
+    /// <summary>
+    /// Resolves (instantiates) a <see cref="System.Type"/> by it's (possibly
+    /// assembly qualified) name, and caches the <see cref="System.Type"/>
+    /// instance against the type name.
+    /// </summary>
+	public class CachedTypeResolver : ITypeResolver
+    {
+        #region Fields
+        /// <summary>
+        /// The cache, mapping type names (<see cref="System.String"/> instances) against
+        /// <see cref="System.Type"/> instances.
+        /// </summary>
+        private IDictionary _typeCache = new HybridDictionary();
+
+        private ITypeResolver _typeResolver = null;
+        #endregion
+
+        #region Constructor (s) / Destructor
+        /// <summary>
+        /// Creates a new instance of the <see cref="IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver"/> class.
+        /// </summary>
+        /// <param name="typeResolver">
+        /// The <see cref="IBatisNet.Common.Utilities.TypesResolver.ITypeResolver"/> that this instance will delegate
+        /// actual <see cref="System.Type"/> resolution to if a <see cref="System.Type"/>
+        /// cannot be found in this instance's <see cref="System.Type"/> cache.
+        /// </param>
+        /// <exception cref="System.ArgumentNullException">
+        /// If the supplied <paramref name="typeResolver"/> is <see langword="null"/>.
+        /// </exception>
+        public CachedTypeResolver(ITypeResolver typeResolver)
+        {
+            _typeResolver = typeResolver;
+        }
+        #endregion
+
+        #region ITypeResolver Members
+
+        /// <summary>
+        /// Resolves the supplied <paramref name="typeName"/> to a
+        /// <see cref="System.Type"/>
+        /// instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The (possibly partially assembly qualified) name of a
+        /// <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the supplied <paramref name="typeName"/> could not be resolved
+        /// to a <see cref="System.Type"/>.
+        /// </exception>
+        public Type Resolve(string typeName)
+        {
+            if (typeName == null || typeName.Trim().Length == 0)
+            {
+                throw new TypeLoadException("Could not load type from string value '" + typeName + "'.");
+            }
+            Type type = null;
+            try
+            {
+                type = _typeCache[typeName] as Type;
+                if (type == null)
+                {
+                    type = _typeResolver.Resolve(typeName);
+                    _typeCache[typeName] = type;
+                }
+            }
+            catch (Exception ex)
+            {
+                if (ex is TypeLoadException)
+                {
+                    throw;
+                }
+                throw new TypeLoadException("Could not load type from string value '" + typeName + "'.", ex);
+            }
+            return type;
+        }
+
+
+        #endregion
+    }
 }

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/ITypeResolver.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/ITypeResolver.cs?rev=408099&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/ITypeResolver.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/ITypeResolver.cs Sat May 20 14:56:36 2006
@@ -0,0 +1,65 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-03-22 22:39:21 +0100 (mer., 22 mars 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *  
+ * 
+ * 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 Remarks
+// Inpspired from Spring.NET
+#endregion
+
+using System;
+
+namespace IBatisNet.Common.Utilities.TypesResolver
+{
+    /// <summary>
+    /// Resolves a <see cref="System.Type"/> by name.
+    /// </summary>
+    /// <remarks>
+    /// <p>
+    /// The rationale behind the creation of this interface is to centralise
+    /// the resolution of type names to <see cref="System.Type"/> instances
+    /// beyond that offered by the plain vanilla
+    /// <see cref="System.Type.GetType(string)"/> method call.
+    /// </p>
+    /// </remarks>
+    public interface ITypeResolver
+    {
+        /// <summary>
+        /// Resolves the supplied <paramref name="typeName"/> to a
+        /// <see cref="System.Type"/>
+        /// instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The (possibly partially assembly qualified) name of a
+        /// <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the supplied <paramref name="typeName"/> could not be resolved
+        /// to a <see cref="System.Type"/>.
+        /// </exception>
+        Type Resolve(string typeName);
+    }
+}
\ No newline at end of file

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeAliasResolver.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeAliasResolver.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeAliasResolver.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeAliasResolver.cs Sat May 20 14:56:36 2006
@@ -1,7 +1,7 @@
 
 #region Apache Notice
 /*****************************************************************************
- * $Revision: 374175 $
+ * $Revision$
  * $LastChangedDate$
  * $LastChangedBy$
  * 
@@ -34,16 +34,22 @@
 
 namespace IBatisNet.Common.Utilities.TypesResolver
 {
-	/// <summary>
-	/// Provides (and resolves) aliases for the common types.
+	/// <summary> 
+	/// Provides access to a central registry of aliased <see cref="System.Type"/>s.
 	/// </summary>
 	/// <remarks>
 	/// <p>
-	/// It's really just syntactic sugar so that a type definition can be referenced as 
-	/// (in, say, a config file) can use 'int' instead of 'System.Int32'.
+	/// Simplifies configuration by allowing aliases to be used instead of
+	/// fully qualified type names.
+	/// </p>
+	/// <p>
+	/// Comes 'pre-loaded' with a number of convenience alias' for the more
+	/// common types; an example would be the '<c>int</c>' (or '<c>Integer</c>'
+	/// for Visual Basic.NET developers) alias for the <see cref="System.Int32"/>
+	/// type.
 	/// </p>
 	/// </remarks>
-	public class TypeAliasResolver
+	public class TypeRegistry
 	{
 		#region Constants
 
@@ -61,10 +67,6 @@
 		/// </summary>
 		public const string BoolAlias = "bool";
 		/// <summary>
-		/// The alias around the 'Boolean' type (Visual Basic.NET style).
-		/// </summary>
-		public const string BoolAliasVB = "Boolean";
-		/// <summary>
 		/// The alias around the 'bool' type.
 		/// </summary>
 		public const string BooleanAlias = "boolean";
@@ -78,10 +80,6 @@
 		/// The alias around the 'char' type.
 		/// </summary>
 		public const string CharAlias = "char";
-		/// <summary>
-		/// The alias around the 'Char' type (Visual Basic.NET style).
-		/// </summary>
-		public const string CharAliasVB = "Char";
 
 		/// <summary>
 		/// The alias around the 'DateTime' type.
@@ -91,28 +89,17 @@
 		/// Another alias around the 'DateTime' type.
 		/// </summary>
 		public const string DateAlias2 = "date";
-		/// <summary>
-		/// The alias around the 'DateTime' type (Visual Basic.NET style).
-		/// </summary>
-		public const string DateAliasVB = "Date";
 
 		/// <summary>
 		/// The alias around the 'decimal' type.
 		/// </summary>
 		public const string DecimalAlias = "decimal";
-		/// <summary>
-		/// The alias around the 'Decimal' type (Visual Basic.NET style).
-		/// </summary>
-		public const string DecimalAliasVB = "Decimal";
 
 		/// <summary>
 		/// The alias around the 'double' type.
 		/// </summary>
 		public const string DoubleAlias = "double";
-		/// <summary>
-		/// The alias around the 'Double' type (Visual Basic.NET style).
-		/// </summary>
-		public const string DoubleAliasVB = "Double";
+
 
 		/// <summary>
 		/// The alias around the 'float' type.
@@ -121,10 +108,6 @@
 		/// <summary>
 		/// Another alias around the 'float' type.
 		/// </summary>
-		public const string FloatAliasVB = "Single";
-		/// <summary>
-		/// Another alias around the 'float' type.
-		/// </summary>
 		public const string SingleAlias = "single";
 
 		/// <summary>
@@ -153,15 +136,12 @@
 		/// Another alias around the 'short' type.
 		/// </summary>
 		public const string Int16Alias2 = "short";
-		/// <summary>
-		/// The alias around the 'Short' type (Visual Basic.NET style).
-		/// </summary>
-		public const string Int16AliasVB = "Short";
+
 
 		/// <summary>
 		/// The alias around the 'int' type.
 		/// </summary>
-		public const string Int32Alias1 = "Int32";
+		public const string Int32Alias1 = "int32";
 		/// <summary>
 		/// Another alias around the 'int' type.
 		/// </summary>
@@ -170,10 +150,6 @@
 		/// Another alias around the 'int' type.
 		/// </summary>
 		public const string Int32Alias3 = "integer";
-		/// <summary>
-		/// The alias around the 'Integer' type (Visual Basic.NET style).
-		/// </summary>
-		public const string Int32AliasVB = "Integer";
 
 		/// <summary>
 		/// The alias around the 'long' type.
@@ -183,10 +159,6 @@
 		/// Another alias around the 'long' type.
 		/// </summary>
 		public const string Int64Alias2 = "long";
-		/// <summary>
-		/// The alias around the 'Long' type (Visual Basic.NET style).
-		/// </summary>
-		public const string Int64AliasVB = "Long";
 
 		/// <summary>
 		/// The alias around the 'unsigned short' type.
@@ -224,25 +196,132 @@
 		/// The alias around the 'string' type.
 		/// </summary>
 		public const string StringAlias = "string";
-		/// <summary>
-		/// The alias around the 'string' type (Visual Basic.NET style).
-		/// </summary>
-		public const string StringAliasVB = "String";
 
 		/// <summary>
 		/// The alias around the 'TimeSpan' type.
 		/// </summary>
 		public const string TimeSpanAlias = "timespan";
 
+#if dotnet2
+        /// <summary>
+        /// The alias around the 'int?' type.
+        /// </summary>
+        public const string NullableInt32Alias = "int?";
+
+        /// <summary>
+        /// The alias around the 'int?[]' array type.
+        /// </summary>
+        public const string NullableInt32ArrayAlias = "int?[]";
+
+        /// <summary>
+        /// The alias around the 'decimal?' type.
+        /// </summary>
+        public const string NullableDecimalAlias = "decimal?";
+
+        /// <summary>
+        /// The alias around the 'decimal?[]' array type.
+        /// </summary>
+        public const string NullableDecimalArrayAlias = "decimal?[]";
+
+        /// <summary>
+        /// The alias around the 'char?' type.
+        /// </summary>
+        public const string NullableCharAlias = "char?";
+
+        /// <summary>
+        /// The alias around the 'char?[]' array type.
+        /// </summary>
+        public const string NullableCharArrayAlias = "char?[]";
+
+        /// <summary>
+        /// The alias around the 'long?' type.
+        /// </summary>
+        public const string NullableInt64Alias = "long?";
+
+        /// <summary>
+        /// The alias around the 'long?[]' array type.
+        /// </summary>
+        public const string NullableInt64ArrayAlias = "long?[]";
+
+        /// <summary>
+        /// The alias around the 'short?' type.
+        /// </summary>
+        public const string NullableInt16Alias = "short?";
+
+        /// <summary>
+        /// The alias around the 'short?[]' array type.
+        /// </summary>
+        public const string NullableInt16ArrayAlias = "short?[]";
+
+        /// <summary>
+        /// The alias around the 'unsigned int?' type.
+        /// </summary>
+        public const string NullableUInt32Alias = "uint?";
+
+        /// <summary>
+        /// The alias around the 'unsigned long?' type.
+        /// </summary>
+        public const string NullableUInt64Alias = "ulong?";
+
+        /// <summary>
+        /// The alias around the 'ulong?[]' array type.
+        /// </summary>
+        public const string NullableUInt64ArrayAlias = "ulong?[]";
+
+        /// <summary>
+        /// The alias around the 'uint?[]' array type.
+        /// </summary>
+        public const string NullableUInt32ArrayAlias = "uint?[]";
+
+        /// <summary>
+        /// The alias around the 'unsigned short?' type.
+        /// </summary>
+        public const string NullableUInt16Alias = "ushort?";
+
+        /// <summary>
+        /// The alias around the 'ushort?[]' array type.
+        /// </summary>
+        public const string NullableUInt16ArrayAlias = "ushort?[]";
+
+        /// <summary>
+        /// The alias around the 'double?' type.
+        /// </summary>
+        public const string NullableDoubleAlias = "double?";
+
+        /// <summary>
+        /// The alias around the 'double?[]' array type.
+        /// </summary>
+        public const string NullableDoubleArrayAlias = "double?[]";
+
+        /// <summary>
+        /// The alias around the 'float?' type.
+        /// </summary>
+        public const string NullableFloatAlias = "float?";
+
+        /// <summary>
+        /// The alias around the 'float?[]' array type.
+        /// </summary>
+        public const string NullableFloatArrayAlias = "float?[]";
+
+        /// <summary>
+        /// The alias around the 'bool?' type.
+        /// </summary>
+        public const string NullableBoolAlias = "bool?";
+
+        /// <summary>
+        /// The alias around the 'bool?[]' array type.
+        /// </summary>
+        public const string NullableBoolArrayAlias = "bool?[]";
+#endif
 		#endregion
 
 		#region Fields
-		private static readonly StringDictionary _aliases = new StringDictionary();
+        private static IDictionary _types = new Hashtable();
 		#endregion
 
 		#region Constructor (s) / Destructor
 		/// <summary>
-		/// Creates a new instance of the TypeAliasFactory class.
+        /// Creates a new instance of the <see cref="TypeRegistry"/> class.
 		/// </summary>
 		/// <remarks>
 		/// <p>
@@ -250,168 +329,124 @@
 		/// constructors.
 		/// </p>
 		/// </remarks>
-		private TypeAliasResolver() {}
+		private TypeRegistry() {}
 
 		/// <summary>
 		/// Initialises the static properties of the TypeAliasResolver class.
 		/// </summary>
-		static TypeAliasResolver()
+        static TypeRegistry()
 		{
 			// Initialize a dictionary with some fully qualifiaed name 
-			_aliases [TypeAliasResolver.ArrayListAlias1] = typeof (ArrayList).FullName;
-			_aliases [TypeAliasResolver.ArrayListAlias2] = typeof (ArrayList).FullName;
+			_types[ArrayListAlias1] = typeof (ArrayList);
+			_types[ArrayListAlias2] = typeof (ArrayList);
 
-			_aliases [TypeAliasResolver.BoolAlias] = typeof (bool).FullName;
-			_aliases [TypeAliasResolver.BoolAliasVB] = typeof (bool).FullName;
-			_aliases [TypeAliasResolver.BooleanAlias] = typeof (bool).FullName;
+			_types[BoolAlias] = typeof (bool);
+			_types[BooleanAlias] = typeof (bool);
 
-			_aliases [TypeAliasResolver.ByteAlias] = typeof (byte).FullName;
+			_types[ByteAlias] = typeof (byte);
 
-			_aliases [TypeAliasResolver.CharAlias] = typeof (char).FullName;
-			_aliases [TypeAliasResolver.CharAliasVB] = typeof (char).FullName;
+			_types[CharAlias] = typeof (char);
 
-			_aliases [TypeAliasResolver.DateAlias1] = typeof (DateTime).FullName;
-			_aliases [TypeAliasResolver.DateAlias2] = typeof (DateTime).FullName;
-			_aliases [TypeAliasResolver.DateAliasVB] = typeof (DateTime).FullName;
+			_types[DateAlias1] = typeof (DateTime);
+			_types[DateAlias2] = typeof (DateTime);
 
-			_aliases [TypeAliasResolver.DecimalAlias] = typeof (decimal).FullName;
-			_aliases [TypeAliasResolver.DecimalAliasVB] = typeof (decimal).FullName;
+			_types[DecimalAlias] = typeof (decimal);
 
-			_aliases [TypeAliasResolver.DoubleAlias] = typeof (double).FullName;
-			_aliases [TypeAliasResolver.DoubleAliasVB] = typeof (double).FullName;
+			_types[DoubleAlias] = typeof (double);
 
-			_aliases [TypeAliasResolver.FloatAlias] = typeof (float).FullName;
-			_aliases [TypeAliasResolver.FloatAliasVB] = typeof (float).FullName;
-			_aliases [TypeAliasResolver.SingleAlias] = typeof (float).FullName;
+			_types[FloatAlias] = typeof (float);
+			_types[SingleAlias] = typeof (float);
 
-			_aliases [TypeAliasResolver.GuidAlias] = typeof (Guid).FullName;
+			_types[GuidAlias] = typeof (Guid);
 
-			_aliases [TypeAliasResolver.HashtableAlias1] = typeof (Hashtable).FullName;
-			_aliases [TypeAliasResolver.HashtableAlias2] = typeof (Hashtable).FullName;
-			_aliases [TypeAliasResolver.HashtableAlias3] = typeof (Hashtable).FullName;
+			_types[HashtableAlias1] = typeof (Hashtable);
+			_types[HashtableAlias2] = typeof (Hashtable);
+			_types[HashtableAlias3] = typeof (Hashtable);
 
-			_aliases [TypeAliasResolver.Int16Alias1] = typeof (short).FullName;
-			_aliases [TypeAliasResolver.Int16Alias2] = typeof (short).FullName;
-			_aliases [TypeAliasResolver.Int16AliasVB] = typeof (short).FullName;
+			_types[Int16Alias1] = typeof (short);
+			_types[Int16Alias2] = typeof (short);
 
-			_aliases [TypeAliasResolver.Int32Alias1] = typeof (int).FullName;
-			_aliases [TypeAliasResolver.Int32Alias2] = typeof (int).FullName;
-			_aliases [TypeAliasResolver.Int32Alias3] = typeof (int).FullName;
-			_aliases [TypeAliasResolver.Int32AliasVB] = typeof (int).FullName;
+			_types[Int32Alias1] = typeof (int);
+			_types[Int32Alias2] = typeof (int);
+			_types[Int32Alias3] = typeof (int);
 
-			_aliases [TypeAliasResolver.Int64Alias1] = typeof (long).FullName;
-			_aliases [TypeAliasResolver.Int64Alias2] = typeof (long).FullName;
-			_aliases [TypeAliasResolver.Int64AliasVB] = typeof (long).FullName;
+			_types[Int64Alias1] = typeof (long);
+			_types[Int64Alias2] = typeof (long);
 
-			_aliases [TypeAliasResolver.UInt16Alias1] = typeof (ushort).FullName;
-			_aliases [TypeAliasResolver.UInt16Alias2] = typeof (ushort).FullName;
+			_types[UInt16Alias1] = typeof (ushort);
+			_types[UInt16Alias2] = typeof (ushort);
 
-			_aliases [TypeAliasResolver.UInt32Alias1] = typeof (uint).FullName;
-			_aliases [TypeAliasResolver.UInt32Alias2] = typeof (uint).FullName;
+			_types[UInt32Alias1] = typeof (uint);
+			_types[UInt32Alias2] = typeof (uint);
 
-			_aliases [TypeAliasResolver.UInt64Alias1] = typeof (ulong).FullName;
-			_aliases [TypeAliasResolver.UInt64Alias2] = typeof (ulong).FullName;
+			_types[UInt64Alias1] = typeof (ulong);
+			_types[UInt64Alias2] = typeof (ulong);
 
-			_aliases [TypeAliasResolver.SByteAlias] = typeof (sbyte).FullName;
+			_types[SByteAlias] = typeof (sbyte);
 
-			_aliases [TypeAliasResolver.StringAlias] = typeof (string).FullName;
-			_aliases [TypeAliasResolver.StringAliasVB] = typeof (string).FullName;
+			_types[StringAlias] = typeof (string);
 
-			_aliases [TypeAliasResolver.TimeSpanAlias] = typeof (string).FullName;
+			_types[TimeSpanAlias] = typeof (string);
 
-		}
-		#endregion
+#if dotnet2
+            _types[NullableInt32Alias] = typeof(int?);
+            _types[NullableInt32ArrayAlias] = typeof(int?[]);
 
-		#region Methods
-		
-		/// <summary>
-		/// Resolves the supplied type name.
-		/// </summary>
-		/// <remarks>
-		/// <p>
-		/// If the supplied type name is an alias, the fully resolved
-		/// type name is returned. If no alias could be found that matches
-		/// the supplied type name, then the type name will be returned as is.
-		/// </p>
-		/// </remarks>
-		/// <param name="type">The supplied type name.</param>
-		/// <returns>
-		/// If the supplied type name is an alias, the fully resolved
-		/// type name is returned. If no alias could be found that matches
-		/// the supplied type name, then the type name will be returned as is.
-		/// </returns>
-		public static string Resolve (string type) 
-		{
-			if (type != null)
-			{
-				if (_aliases.ContainsKey (type.ToLower ())) 
-				{
-					return _aliases [type] as string;
-				}
-			}
-			return type;
-		}
+            _types[NullableDecimalAlias] = typeof(decimal?);
+            _types[NullableDecimalArrayAlias] = typeof(decimal?[]);
 
+            _types[NullableCharAlias] = typeof(char?);
+            _types[NullableCharArrayAlias] = typeof(char?[]);
 
-		/// <summary>
-		/// Instantiate a 'Primitive' Type.
-		/// </summary>
-		/// <param name="typeCode">a typeCode.</param>
-		/// <returns>An object.</returns>
-		public static object InstantiatePrimitiveType(TypeCode typeCode)
-		{
-			object resultObject = null;
+            _types[NullableInt64Alias] = typeof(long?);
+            _types[NullableInt64ArrayAlias] = typeof(long?[]);
+
+            _types[NullableInt16Alias] = typeof(short?);
+            _types[NullableInt16ArrayAlias] = typeof(short?[]);
+
+            _types[NullableUInt32Alias] = typeof(uint?);
+            _types[NullableUInt32ArrayAlias] = typeof(uint?[]);
+
+            _types[NullableUInt64Alias] = typeof(ulong?);
+            _types[NullableUInt64ArrayAlias] = typeof(ulong?[]);
+
+            _types[NullableUInt16Alias] = typeof(ushort?);
+            _types[NullableUInt16ArrayAlias] = typeof(ushort?[]);
+
+            _types[NullableDoubleAlias] = typeof(double?);
+            _types[NullableDoubleArrayAlias] = typeof(double?[]);
+
+            _types[NullableFloatAlias] = typeof(float?);
+            _types[NullableFloatArrayAlias] = typeof(float?[]);
+
+            _types[NullableBoolAlias] = typeof(bool?);
+            _types[NullableBoolArrayAlias] = typeof(bool?[]);
+#endif
+        }
+		#endregion
+
+		#region Methods
 
-			switch(typeCode)
-			{
-				case TypeCode.Boolean :
-					resultObject = new Boolean();
-					break;
-				case TypeCode.Byte :
-					resultObject = new Byte();
-					break;
-				case TypeCode.Char :
-					resultObject = new Char();
-					break;						
-				case TypeCode.DateTime :
-					resultObject = new DateTime();
-					break;
-				case TypeCode.Decimal :
-					resultObject = new Decimal();
-					break;
-				case TypeCode.Double :
-					resultObject = new Double();
-					break;	
-				case TypeCode.Int16 :
-					resultObject = new Int16();
-					break;	
-				case TypeCode.Int32 :
-					resultObject = new Int32();
-					break;	
-				case TypeCode.Int64 :
-					resultObject = new Int64();
-					break;	
-				case TypeCode.SByte :
-					resultObject = new SByte();
-					break;	
-				case TypeCode.Single :
-					resultObject = new Single();
-					break;	
-				case TypeCode.String :
-					resultObject = "";
-					break;	
-				case TypeCode.UInt16 :
-					resultObject = new UInt16();
-					break;		
-				case TypeCode.UInt32 :
-					resultObject = new UInt32();
-					break;	
-				case TypeCode.UInt64 :
-					resultObject = new UInt64();
-					break;		
-			}
-			return resultObject;
-		}
+        /// <summary> 
+        /// Resolves the supplied <paramref name="alias"/> to a <see cref="System.Type"/>. 
+        /// </summary> 
+        /// <param name="alias">
+        /// The alias to resolve.
+        /// </param>
+        /// <returns>
+        /// The <see cref="System.Type"/> the supplied <paramref name="alias"/> was
+        /// associated with, or <see lang="null"/> if no <see cref="System.Type"/> 
+        /// was previously registered for the supplied <paramref name="alias"/>.
+        /// </returns>
+        /// <remarks>The alis name will be convert in lower character before the resolution.</remarks>
+        /// <exception cref="System.ArgumentNullException">
+        /// If the supplied <paramref name="alias"/> is <see langword="null"/> or
+        /// contains only whitespace character(s).
+        /// </exception>
+        public static Type ResolveType(string alias)
+        {
+            return (Type)_types[alias.ToLower()];
+        }
 
 		#endregion
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs Sat May 20 14:56:36 2006
@@ -1,7 +1,7 @@
 
 #region Apache Notice
 /*****************************************************************************
- * $Revision: 382490 $
+ * $Revision$
  * $LastChangedDate$
  * $LastChangedBy$
  * 
@@ -25,15 +25,22 @@
 #endregion
 
 #region Remarks
-// Code from Spring.NET
+// Inpspired from Spring.NET
 #endregion
 
-#region Imports
+#region Using
 
 using System;
+using System.Collections;
+#if dotnet2
+using System.Collections.Generic;
+#endif
 using System.Reflection;
 
 using IBatisNet.Common.Exceptions;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
 #endregion
 
 namespace IBatisNet.Common.Utilities.TypesResolver
@@ -49,8 +56,10 @@
 	/// </p>
 	/// </remarks>
 	/// <version>$Id: TypeResolver.cs,v 1.5 2004/09/28 07:51:47 springboy Exp $</version>
-	public class TypeResolver
+    public class TypeResolver : ITypeResolver
 	{
+        private const string NULLABLE_TYPE = "System.Nullable";
+
 		#region Constructor (s) / Destructor
 		/// <summary>
 		/// Creates a new instance of the TypeResolver class.
@@ -58,177 +67,553 @@
 		public TypeResolver () {}
 		#endregion
 
-		#region Methods
-		/// <summary>
-		/// Resolves the supplied type name into a <see cref="System.Type"/>
-		/// instance.
-		/// </summary>
-		/// <param name="typeName">
-		/// The (possibly partially assembly qualified) name of a <see cref="System.Type"/>.
-		/// </param>
-		/// <returns>
-		/// A resolved <see cref="System.Type"/> instance.
-		/// </returns>
-		/// <exception cref="System.TypeLoadException">
-		/// If the type could not be resolved.
-		/// </exception>
-		public virtual Type Resolve (string typeName)
-		{
+        #region ITypeResolver Members
+        /// <summary>
+        /// Resolves the supplied <paramref name="typeName"/> to a
+        /// <see cref="System.Type"/> instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The unresolved name of a <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the supplied <paramref name="typeName"/> could not be resolved
+        /// to a <see cref="System.Type"/>.
+        /// </exception>
+        public virtual Type Resolve(string typeName)
+        {
+#if dotnet2
+            Type type = ResolveGenericType(typeName);
+            if (type == null)
+            {
+                type = ResolveType(typeName);
+            }
+            return type;
+#else
+            return ResolveType(typeName);
+#endif
+        }
+        #endregion
 
-			#region Sanity Check
+#if dotnet2
+        /// <summary>
+        /// Resolves the supplied generic <paramref name="typeName"/>,
+        /// substituting recursively all its type parameters., 
+        /// to a <see cref="System.Type"/> instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The (possibly generic) name of a <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the supplied <paramref name="typeName"/> could not be resolved
+        /// to a <see cref="System.Type"/>.
+        /// </exception>
+        private Type ResolveGenericType(string typeName)
+        {
+            #region Sanity Check
 			if (typeName ==  null || typeName.Trim().Length==0)
 			{
-				throw new ConfigurationException (
-					"Could not load type with a null or zero length parameter.");
+                throw BuildTypeLoadException(typeName);
 			}
 			#endregion
 
-			Type type = null;
-			string canonicalTypeName = TypeAliasResolver.Resolve (typeName);
-			TypeAssemblyInfo typeInfo = new TypeAssemblyInfo (canonicalTypeName);
-			if (typeInfo.IsAssemblyQualified)
-			{
-				// assembly qualified... load the assembly, then the Type
-				Assembly assembly = null;
+            if (typeName.Contains(NULLABLE_TYPE))
+            {
+                return null;
+            }
+            else
+            {
+                GenericArgumentsInfo genericInfo = new GenericArgumentsInfo(typeName);
+                Type type = null;
+                try
+                {
+                    if (genericInfo.ContainsGenericArguments)
+                    {
+                        type = TypeUtils.ResolveType(genericInfo.GenericTypeName);
+                        if (!genericInfo.IsGenericDefinition)
+                        {
+                            string[] unresolvedGenericArgs = genericInfo.GetGenericArguments();
+                            Type[] genericArgs = new Type[unresolvedGenericArgs.Length];
+                            for (int i = 0; i < unresolvedGenericArgs.Length; i++)
+                            {
+                                genericArgs[i] = TypeUtils.ResolveType(unresolvedGenericArgs[i]);
+                            }
+                            type = type.MakeGenericType(genericArgs);
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    if (ex is TypeLoadException)
+                    {
+                        throw;
+                    }
+                    throw BuildTypeLoadException(typeName, ex);
+                }
+                return type;
+            }
+        }
+#endif
+
+        /// <summary>
+        /// Resolves the supplied <paramref name="typeName"/> to a
+        /// <see cref="System.Type"/>
+        /// instance.
+        /// </summary>
+        /// <param name="typeName">
+        /// The (possibly partially assembly qualified) name of a
+        /// <see cref="System.Type"/>.
+        /// </param>
+        /// <returns>
+        /// A resolved <see cref="System.Type"/> instance.
+        /// </returns>
+        /// <exception cref="System.TypeLoadException">
+        /// If the supplied <paramref name="typeName"/> could not be resolved
+        /// to a <see cref="System.Type"/>.
+        /// </exception>
+        private Type ResolveType(string typeName)
+        {
+            #region Sanity Check
+            if (typeName == null || typeName.Trim().Length == 0)
+            {
+                throw BuildTypeLoadException(typeName);
+            }
+            #endregion
+
+            TypeAssemblyInfo typeInfo = new TypeAssemblyInfo(typeName);
+            Type type = null;
+            try
+            {
+                type = (typeInfo.IsAssemblyQualified) ?
+                     LoadTypeDirectlyFromAssembly(typeInfo) :
+                     LoadTypeByIteratingOverAllLoadedAssemblies(typeInfo);
+            }
+            catch (Exception ex)
+            {
+                throw BuildTypeLoadException(typeName, ex);
+            }
+            if (type == null)
+            {
+                throw BuildTypeLoadException(typeName);
+            }
+            return type;
+        }
+
+        /// <summary>
+        /// Uses <see cref="System.Reflection.Assembly.LoadWithPartialName(string)"/>
+        /// to load an <see cref="System.Reflection.Assembly"/> and then the attendant
+        /// <see cref="System.Type"/> referred to by the <paramref name="typeInfo"/>
+        /// parameter.
+        /// </summary>
+        /// <remarks>
+        /// <p>
+        /// <see cref="System.Reflection.Assembly.LoadWithPartialName(string)"/> is
+        /// deprecated in .NET 2.0, but is still used here (even when this class is
+        /// compiled for .NET 2.0);
+        /// <see cref="System.Reflection.Assembly.LoadWithPartialName(string)"/> will
+        /// still resolve (non-.NET Framework) local assemblies when given only the
+        /// display name of an assembly (the behaviour for .NET Framework assemblies
+        /// and strongly named assemblies is documented in the docs for the
+        /// <see cref="System.Reflection.Assembly.LoadWithPartialName(string)"/> method).
+        /// </p>
+        /// </remarks>
+        /// <param name="typeInfo">
+        /// The assembly and type to be loaded.
+        /// </param>
+        /// <returns>
+        /// A <see cref="System.Type"/>, or <see lang="null"/>.
+        /// </returns>
+        /// <exception cref="System.Exception">
+        /// <see cref="System.Reflection.Assembly.LoadWithPartialName(string)"/>
+        /// </exception>
+        private static Type LoadTypeDirectlyFromAssembly(TypeAssemblyInfo typeInfo)
+        {
+            Type type = null;
+            // assembly qualified... load the assembly, then the Type
+            Assembly assembly = null;
+
 #if dotnet2
-                assembly = Assembly.Load(typeInfo.AssemblyName);
+            assembly = Assembly.Load(typeInfo.AssemblyName);
 #else
-                assembly = Assembly.LoadWithPartialName (typeInfo.AssemblyName);
+            assembly = Assembly.LoadWithPartialName (typeInfo.AssemblyName);
 #endif
-                if (assembly != null)
-				{
-					type = assembly.GetType (typeInfo.TypeName, true, true);
-				}
-			} 
-			else
-			{
-				// bare type name... loop thru all loaded assemblies
-				Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
-				foreach (Assembly assembly in assemblies)
-				{
-					type = assembly.GetType (typeInfo.TypeName, false, false);
-					if (type != null)
-					{
-						break;
-					}
-				}
-			}
-			if (type == null) 
-			{
-				throw new TypeLoadException (
-					"Could not load type : " + typeName);
-			}
-			return type;
-		}
-		#endregion
 
-		#region Inner Class : TypeAssemblyInfo
-		/// <summary>
-		/// Holds data about a <see cref="System.Type"/> and it's
-		/// attendant <see cref="System.Reflection.Assembly"/>.
-		/// </summary>
-		internal class TypeAssemblyInfo
-		{
-			#region Constants
-			/// <summary>
-			/// The string that separates <see cref="System.Type"/> names
-			/// from their attendant <see cref="System.Reflection.Assembly"/>
-			/// names in an assembly qualified type name.
-			/// </summary>
-			public const string TYPE_ASSEMBLY_SEPARATOR = ",";
+            if (assembly != null)
+            {
+                type = assembly.GetType(typeInfo.TypeName, true, true);
+            }
+            return type;
+        }
+
+        /// <summary>
+        /// Check all assembly
+        /// to load the attendant <see cref="System.Type"/> referred to by 
+        /// the <paramref name="typeInfo"/> parameter.
+        /// </summary>
+        /// <param name="typeInfo">
+        /// The type to be loaded.
+        /// </param>
+        /// <returns>
+        /// A <see cref="System.Type"/>, or <see lang="null"/>.
+        /// </returns>
+        private static Type LoadTypeByIteratingOverAllLoadedAssemblies(TypeAssemblyInfo typeInfo)
+        {
+            Type type = null;
+            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
+            foreach (Assembly assembly in assemblies)
+            {
+                type = assembly.GetType(typeInfo.TypeName, false, false);
+                if (type != null)
+                {
+                    break;
+                }
+            }
+            return type;
+        }
+
+        private static TypeLoadException BuildTypeLoadException(string typeName)
+        {
+            return new TypeLoadException("Could not load type from string value '" + typeName + "'.");
+        }
+
+        private static TypeLoadException BuildTypeLoadException(string typeName, Exception ex)
+        {
+            return new TypeLoadException("Could not load type from string value '" + typeName + "'.", ex);
+        }
+
+#if dotnet2
+        #region Inner Class : GenericArgumentsInfo
+
+        /// <summary>
+        /// Holder for the generic arguments when using type parameters.
+        /// </summary>
+        /// <remarks>
+        /// <p>
+        /// Type parameters can be applied to classes, interfaces, 
+        /// structures, methods, delegates, etc...
+        /// </p>
+        /// </remarks>
+        internal class GenericArgumentsInfo
+        {
+        #region Constants
+
+            /// <summary>
+            /// The generic arguments prefix.
+            /// </summary>
+            public const string GENERIC_ARGUMENTS_PREFIX = "[[";
+
+            /// <summary>
+            /// The generic arguments suffix.
+            /// </summary>
+            public const string GENERIC_ARGUMENTS_SUFFIX = "],";
+
+            /// <summary>
+            /// The character that separates a list of generic arguments.
+            /// </summary>
+            public const string GENERIC_ARGUMENTS_SEPARATOR = "],[";
+            
+            private const char GENERIC_ARGUMENT_SUFFIX = '[';
+            private const char GENERIC_ARGUMENT_PREFIX = ']';
+
+        #endregion
+
+        #region Fields
+
+            private string _unresolvedGenericTypeName = string.Empty;
+            private string _unresolvedGenericMethodName = string.Empty;
+            private string[] _unresolvedGenericArguments = null;
+
+            #endregion
+
+        #region Constructor (s) / Destructor
+
+            /// <summary>
+            /// Creates a new instance of the GenericArgumentsInfo class.
+            /// </summary>
+            /// <param name="value">
+            /// The string value to parse looking for a generic definition
+            /// and retrieving its generic arguments.
+            /// </param>
+            public GenericArgumentsInfo(string value)
+            {
+                ParseGenericArguments(value);
+            }
+
+            #endregion
+
+        #region Properties
+
+            /// <summary>
+            /// The (unresolved) generic type name portion 
+            /// of the original value when parsing a generic type.
+            /// </summary>
+            public string GenericTypeName
+            {
+                get { return _unresolvedGenericTypeName; }
+            }
+
+            /// <summary>
+            /// The (unresolved) generic method name portion 
+            /// of the original value when parsing a generic method.
+            /// </summary>
+            public string GenericMethodName
+            {
+                get { return _unresolvedGenericMethodName; }
+            }
+
+            /// <summary>
+            /// Is the string value contains generic arguments ?
+            /// </summary>
+            /// <remarks>
+            /// <p>
+            /// A generic argument can be a type parameter or a type argument.
+            /// </p>
+            /// </remarks>
+            public bool ContainsGenericArguments
+            {
+                get
+                {
+                    return (_unresolvedGenericArguments != null &&
+                        _unresolvedGenericArguments.Length > 0);
+                }
+            }
+
+            /// <summary>
+            /// Is generic arguments only contains type parameters ?
+            /// </summary>
+            public bool IsGenericDefinition
+            {
+                get
+                {
+                    if (_unresolvedGenericArguments == null)
+                        return false;
+
+                    foreach (string arg in _unresolvedGenericArguments)
+                    {
+                        if (arg.Length > 0)
+                            return false;
+                    }
+                    return true;
+                }
+            }
+
+            #endregion
+
+        #region Methods
+
+            /// <summary>
+            /// Returns an array of unresolved generic arguments types.
+            /// </summary>
+            /// <remarks>
+            /// <p>
+            /// A empty string represents a type parameter that 
+            /// did not have been substituted by a specific type.
+            /// </p>
+            /// </remarks>
+            /// <returns>
+            /// An array of strings that represents the unresolved generic 
+            /// arguments types or an empty array if not generic.
+            /// </returns>
+            public string[] GetGenericArguments()
+            {
+                if (_unresolvedGenericArguments == null)
+                {
+                    return new string[] { };
+                }
+
+                return _unresolvedGenericArguments;
+            }
+
+            private void ParseGenericArguments(string originalString)
+            {
+                RegexOptions options = RegexOptions.None;
+                Regex regex = new Regex(@".*`\d*\[\[", options);
+                // Check for match
+                bool isMatch = regex.IsMatch(originalString);
+
+                if (!isMatch)
+                {
+                    _unresolvedGenericTypeName = originalString;
+                    _unresolvedGenericMethodName = originalString;
+                }
+                else
+                {
+                    //.*'\d*\[\[
+                    //http://developpeur.journaldunet.com/tutoriel/php/030303php_regexp1a.shtml
+                    //http://www.asp-php.net/tutorial/asp-php/regexp.php
+
+                    int argsStartIndex = originalString.IndexOf(GENERIC_ARGUMENTS_PREFIX);
+                    int argsEndIndex = originalString.LastIndexOf(GENERIC_ARGUMENTS_SUFFIX);
+                    if (argsEndIndex != -1)
+                    {
+                        _unresolvedGenericMethodName = originalString.Remove(
+                            argsStartIndex, argsEndIndex - argsStartIndex + 1);
+
+                        SplitGenericArguments(originalString.Substring(
+                            argsStartIndex + 1, argsEndIndex - argsStartIndex - 1));
+
+                        _unresolvedGenericTypeName = originalString.Replace(
+                            originalString.Substring(argsStartIndex-2, argsEndIndex - argsStartIndex + 3),
+                            "`" + _unresolvedGenericArguments.Length);
+                    }
+                }
+            }
+
+            private void SplitGenericArguments(string originalArgs)
+            {
+                IList<string> arguments = new List<string>();
+
+                if (originalArgs.Contains(GENERIC_ARGUMENTS_SEPARATOR))
+                {
+                    arguments = Parse(originalArgs);
+                }
+                else
+                {
+                    string argument = originalArgs.Substring(1, originalArgs.Length - 2).Trim();
+                    arguments.Add(argument);
+                }
+                _unresolvedGenericArguments = new string[arguments.Count];
+                 arguments.CopyTo(_unresolvedGenericArguments, 0);
+           }
+
+            private IList<string> Parse(string args)
+            {
+                StringBuilder argument = null;
+                IList<string> arguments = new List<string>();
+
+                TextReader input = new StringReader(args);
+                bool hasReadRightDelimiter = false;
+                do
+                {
+                    char ch = (char)input.Read();
+                    if (ch == '[')
+                    {
+                        argument = new StringBuilder();
+                        hasReadRightDelimiter = false;
+                    }
+                    else if (ch == ']')
+                    {
+                        arguments.Add(argument.ToString());
+                        hasReadRightDelimiter = true;
+                    }
+                    else if (ch == ',' && hasReadRightDelimiter)
+                    {
+                        hasReadRightDelimiter = false;
+                    }
+                    else
+                    {
+                        argument.Append(ch);
+                        hasReadRightDelimiter = false;
+                    }
+                }
+                while (input.Peek() != -1);
+
+                return arguments;
+            }
+            #endregion
+        }
+
+        #endregion
+#endif
+
+        #region Inner Class : TypeAssemblyInfo
+
+        /// <summary>
+        /// Holds data about a <see cref="System.Type"/> and it's
+        /// attendant <see cref="System.Reflection.Assembly"/>.
+        /// </summary>
+        internal class TypeAssemblyInfo
+        {
+            #region Constants
+
+            /// <summary>
+            /// The string that separates a <see cref="System.Type"/> name
+            /// from the name of it's attendant <see cref="System.Reflection.Assembly"/>
+            /// in an assembly qualified type name.
+            /// </summary>
+            public const string TYPE_ASSEMBLY_SEPARATOR = ",";
             public const string NULLABLE_TYPE = "System.Nullable";
             public const string NULLABLE_TYPE_ASSEMBLY_SEPARATOR = "]],";
-			#endregion
+            #endregion
+
+            #region Fields
 
-			#region Fields
-			private string _unresolvedAssemblyName = string.Empty;
+            private string _unresolvedAssemblyName = string.Empty;
             private string _unresolvedTypeName = string.Empty;
-            private bool _isNullable = false;
 
-			#endregion
+            #endregion
 
-			#region Properties
+            #region Constructor (s) / Destructor
 
             /// <summary>
-            /// Indicatre if the type is a nullable type.
+            /// Creates a new instance of the TypeAssemblyInfo class.
             /// </summary>
-            public bool IsNullable
+            /// <param name="unresolvedTypeName">
+            /// The unresolved name of a <see cref="System.Type"/>.
+            /// </param>
+            public TypeAssemblyInfo(string unresolvedTypeName)
             {
-                get { return _isNullable; }
+                SplitTypeAndAssemblyNames(unresolvedTypeName);
             }
 
-			/// <summary>
-			/// The (unresolved) type name portion of the original type name.
-			/// </summary>
-			public string TypeName
-			{
-				get { return _unresolvedTypeName; }
-			}
+            #endregion
 
-			/// <summary>
-			/// The (unresolved, possibly partial) name of the attandant assembly.
-			/// </summary>
-			public string AssemblyName
-			{
-				get { return _unresolvedAssemblyName; }
-			}
+            #region Properties
 
-			/// <summary>
-			/// Is the type name being resolved assembly qualified?
-			/// </summary>
-			public bool IsAssemblyQualified
-			{
-				get
-				{
-					if (AssemblyName ==  null || AssemblyName.Trim().Length==0)
-					{
-						return false;
-					}
-					else
-					{
-						return true;
-					}
-				}
-			}
+            /// <summary>
+            /// The (unresolved) type name portion of the original type name.
+            /// </summary>
+            public string TypeName
+            {
+                get { return _unresolvedTypeName; }
+            }
 
-			/// <summary>
-			/// The (possibly assembly qualified) <see cref="System.Type"/> name.
-			/// </summary>
-			public string OriginalTypeName
-			{
-				get
-				{
-					System.Text.StringBuilder buffer = new System.Text.StringBuilder (TypeName);
-					if (IsAssemblyQualified) 
-					{
-                        buffer.Append(TYPE_ASSEMBLY_SEPARATOR);
-						buffer.Append (AssemblyName);
-					}
-					return buffer.ToString ();
-				}
-			}
-			#endregion
+            /// <summary>
+            /// The (unresolved, possibly partial) name of the attandant assembly.
+            /// </summary>
+            public string AssemblyName
+            {
+                get { return _unresolvedAssemblyName; }
+            }
 
-			#region Constructor (s) / Destructor
-			/// <summary>
-			/// Creates a new instance of the TypeAssemblyInfo class.
-			/// </summary>
-			/// <param name="unresolvedTypeName">
-			/// The unresolved name of a <see cref="System.Type"/>.
-			/// </param>
-			public TypeAssemblyInfo (string unresolvedTypeName)
-			{
-				SplitTypeAndAssemblyNames (unresolvedTypeName);
-			}
-			#endregion
+            /// <summary>
+            /// Is the type name being resolved assembly qualified?
+            /// </summary>
+            public bool IsAssemblyQualified
+            {
+                get { return HasText(AssemblyName); }
+            }
 
+            #endregion
 
-			#region Methods
-			private void SplitTypeAndAssemblyNames (string originalTypeName) 
-			{
+            #region Methods
+
+            private bool HasText(string target)
+            {
+                if (target == null)
+                {
+                    return false;
+                }
+                else
+                {
+                    return HasLength(target.Trim());
+                }
+            }
+
+            private bool HasLength(string target)
+            {
+                return (target != null && target.Length > 0);
+            }
+
+            private void SplitTypeAndAssemblyNames(string originalTypeName)
+            {
                 if (originalTypeName.StartsWith(TypeAssemblyInfo.NULLABLE_TYPE))
                 {
-                    _isNullable = true;
                     int typeAssemblyIndex = originalTypeName.IndexOf(TypeAssemblyInfo.NULLABLE_TYPE_ASSEMBLY_SEPARATOR);
                     if (typeAssemblyIndex < 0)
                     {
@@ -242,8 +627,7 @@
                 }
                 else
                 {
-                    int typeAssemblyIndex = originalTypeName.IndexOf(TypeAssemblyInfo.TYPE_ASSEMBLY_SEPARATOR);
-                    _isNullable = false;
+                    int typeAssemblyIndex = originalTypeName.IndexOf(TYPE_ASSEMBLY_SEPARATOR);
                     if (typeAssemblyIndex < 0)
                     {
                         _unresolvedTypeName = originalTypeName;
@@ -254,10 +638,11 @@
                         _unresolvedAssemblyName = originalTypeName.Substring(typeAssemblyIndex + 1).Trim();
                     }
                 }
-			}
-			#endregion
+            }
 
-		}
-		#endregion
-	}
+            #endregion
+        }
+
+        #endregion
+    }
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs Sat May 20 14:56:36 2006
@@ -1,10 +1,7 @@
 using System;
 using System.Collections;
-
-using NUnit.Framework;
-
-using IBatisNet.DataMapper.Test.NUnit;
 using IBatisNet.DataMapper.Test.Domain;
+using NUnit.Framework;
 
 namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests.MSSQL
 {
@@ -133,11 +130,16 @@
             sqlMap.BeginTransaction();
             sqlMap.Insert("InsertAccountViaStoreProcedure", account);
 
-            Account testAccount = sqlMap.QueryForObject("GetAccountViaColumnName", 99) as Account;
+            Hashtable map = new Hashtable();
+            map.Add("Id", 0);
+            map.Add("Name", "Toto");
+            map.Add("Guid", Guid.NewGuid());
+
+            sqlMap.Insert("InsertCategoryViaStoreProcedureWithMap", map);
+            Assert.AreEqual(1, map["Id"]);
+
             sqlMap.CommitTransaction();
 
-            Assert.IsNotNull(testAccount);
-            Assert.AreEqual(99, testAccount.Id);
         }
 		#endregion
 	}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs Sat May 20 14:56:36 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper
@@ -124,7 +124,7 @@
 		/// </summary>
 		public void Initialize()
 		{
-			_class = Resources.TypeForName(_className);
+            _class = TypeUtils.ResolveType(_className);
 		}
 		#endregion
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs Sat May 20 14:56:36 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper
@@ -112,7 +112,7 @@
 		/// </summary>
 		public void Initialize()
 		{
-			_class = Resources.TypeForName(_className);
+            _class = TypeUtils.ResolveType(_className);
 		}
 		#endregion
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs Sat May 20 14:56:36 2006
@@ -1,7 +1,7 @@
 
 #region Apache Notice
 /*****************************************************************************
- * $Revision: 368065 $
+ * $Revision$
  * $LastChangedDate$
  * $LastChangedBy$
  * 
@@ -207,7 +207,7 @@
 				}
 
 				// Build the CacheController
-				Type type = Resources.TypeForName(_implementation);
+                Type type = TypeUtils.ResolveType(_implementation);
 				object[] arguments = new object[0];
 
 				_controller = (ICacheController)Activator.CreateInstance(type, arguments);

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs Sat May 20 14:56:36 2006
@@ -353,7 +353,7 @@
 				{
 					try 
 					{
-						Type typeClass = Resources.TypeForName( propertyType );
+                        Type typeClass = TypeUtils.ResolveType(propertyType);
 						handler = typeHandlerFactory.GetTypeHandler(typeClass, dbType);
 					} 
 					catch (Exception e) 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Sat May 20 14:56:36 2006
@@ -329,8 +329,8 @@
                     _typeHandler = scope.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler();
 				}
 				else // If we specify a CLR type, use it
-				{ 
-					Type type = Resources.TypeForName(this.CLRType);
+				{
+                    Type type = TypeUtils.ResolveType(this.CLRType);
 
                     if (scope.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(type)) 
 					{

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ArgumentProperty.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ArgumentProperty.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ArgumentProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ArgumentProperty.cs Sat May 20 14:56:36 2006
@@ -194,7 +194,7 @@
 				{
 					try 
 					{
-						Type type = Resources.TypeForName(clrType);
+                        Type type = TypeUtils.ResolveType(clrType);
 						handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
 					} 
 					catch (Exception e) 
@@ -223,7 +223,7 @@
 				{
 					try 
 					{
-						Type type = Resources.TypeForName(clrType);
+                        Type type = TypeUtils.ResolveType(clrType);
 						handler = configScope.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
 					} 
 					catch (Exception e) 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Sat May 20 14:56:36 2006
@@ -38,6 +38,7 @@
 using IBatisNet.DataMapper.DataExchange;
 using IBatisNet.DataMapper.Exceptions;
 using IBatisNet.DataMapper.Scope;
+using IBatisNet.Common.Utilities;
 
 #endregion
 
@@ -393,7 +394,7 @@
 			}
 			else
 			{
-				return TypeAliasResolver.InstantiatePrimitiveType(typeCode);
+                return TypeUtils.InstantiatePrimitiveType(typeCode);
 			}
 		}
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs Sat May 20 14:56:36 2006
@@ -82,11 +82,11 @@
 			configScope.ErrorContext.MoreInfo = "Check the type attribute '" + handler.ClassName + "' (must be a class name) or the dbType '" + handler.DbType + "' (must be a DbType type name).";
 			if (handler.DbType!= null && handler.DbType.Length > 0) 
 			{
-				configScope.DataExchangeFactory.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), handler.DbType, typeHandler);
+                configScope.DataExchangeFactory.TypeHandlerFactory.Register(TypeUtils.ResolveType(handler.ClassName), handler.DbType, typeHandler);
 			} 
 			else 
 			{
-				configScope.DataExchangeFactory.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), typeHandler);
+                configScope.DataExchangeFactory.TypeHandlerFactory.Register(TypeUtils.ResolveType(handler.ClassName), typeHandler);
 			}
 		}
 	}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs?rev=408099&r1=408098&r2=408099&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs Sat May 20 14:56:36 2006
@@ -41,6 +41,7 @@
 using IBatisNet.DataMapper.Configuration.Sql;
 using IBatisNet.DataMapper.Exceptions;
 using IBatisNet.DataMapper.Scope;
+using IBatisNet.Common.Utilities;
 
 #endregion
 
@@ -346,7 +347,7 @@
 			if (_resultClass.IsPrimitive || _resultClass == typeof (string))
 			{
 				TypeCode typeCode = Type.GetTypeCode(_resultClass);
-				return TypeAliasResolver.InstantiatePrimitiveType(typeCode);
+                return TypeUtils.InstantiatePrimitiveType(typeCode);
 			}
 			else
 			{