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/12 23:09:45 UTC
svn commit: r169887 - in
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper: ./ Configuration/
Configuration/Alias/ Configuration/ParameterMapping/
Configuration/ResultMapping/ Configuration/Sql/Dynamic/
Configuration/Sql/SimpleDynamic/ MappedStatements/ Scope/ Test/Domain/
Test/Maps/MSSQL/Odbc/ Test/Maps/MSSQL/OleDb/ Test/Maps/MSSQL/SqlClient/
Test/Maps/MySql/ByteFx/ Test/Maps/MySql/MySql/ Test/Maps/Oracle/ODP/
Test/Maps/Oracle/OracleClient/ Test/bin/Debug/ TypeHandlers/
Author: gbayon
Date: Thu May 12 14:09:43 2005
New Revision: 169887
URL: http://svn.apache.org/viewcvs?rev=169887&view=rev
Log:
- Added support for <typeHandlers> (see SqlMap.config files in test unit)
<typeHandlers>
<typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
</typeHandlers>
Need to do same Unit tests as in Java
Added:
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
Modified:
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/CacheKey.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/YesNoBoolTypeHandlerCallback.cs Thu May 12 14:09:43 2005
@@ -7,7 +7,11 @@
/// <summary>
/// YesNoBoolTypeHandlerCallback.
/// </summary>
- public class YesNoBoolTypeHandlerCallback : ITypeHandlerCallback
+ /// <remarks>
+ /// Used in account.xml on
+ /// < result property="BannerOption" type="Bit" dbType="Varchar" column="Account_Banner_Option" />
+ /// </remarks>
+ public class OuiNonBoolTypeHandlerCallback : ITypeHandlerCallback
{
private const string YES = "Oui";
private const string NO = "Non";
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/Odbc/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MySql/MySql/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
<resultMaps>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
<typeAlias alias="OneZeroBool" type="IBatisNet.DataMapper.Test.Domain.OneZeroBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Other.xml Thu May 12 14:09:43 2005
@@ -4,7 +4,6 @@
<alias>
<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
- <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
<typeAlias alias="OneZeroBool" type="IBatisNet.DataMapper.Test.Domain.OneZeroBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Access_OleDb.config Thu May 12 14:09:43 2005
@@ -17,8 +17,13 @@
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test" />
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<sqlMap resource="../../Maps/Access/OleDb/Account.xml"/>
<sqlMap resource="../../Maps/Access/OleDb/DynamicAccount.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_Odbc.config Thu May 12 14:09:43 2005
@@ -18,8 +18,13 @@
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test" />
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<sqlMap resource="../../Maps/MSSQL/Odbc/Account.xml"/>
<sqlMap resource="../../Maps/MSSQL/Odbc/DynamicAccount.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_OleDb.config Thu May 12 14:09:43 2005
@@ -18,8 +18,12 @@
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test" />
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
<sqlMaps>
<sqlMap resource="../../Maps/MSSQL/OleDb/Account.xml"/>
<sqlMap resource="../../Maps/MSSQL/OleDb/DynamicAccount.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Thu May 12 14:09:43 2005
@@ -19,9 +19,16 @@
<provider name="sqlServer1.1"/>
<dataSource name="iBatisNet" connectionString="data source=${datasource};database=${database};user id=${userid};password=${password};connection reset=false;connection lifetime=5; min pool size=1; max pool size=50"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<!-- <sqlMap url="E:/Projet/IBatisNet/Source/IBatisNet.Test/Maps/MSSQL/SqlClient/Account.xml"/> ok -->
<sqlMap resource="../../Maps/MSSQL/SqlClient/Account.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_ByteFx.config Thu May 12 14:09:43 2005
@@ -16,9 +16,16 @@
<provider name="ByteFx"/>
<dataSource name="IBatisNet" connectionString="Data Source=${datasourceMySql};Database=${database};User Id=${userid};Password=${password}"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<!-- <sqlMap url="E:/Projet/IBatisNet/Source/IBatisNet.Test/Maps/MySql/ByteFx/Account.xml"/> ok -->
<sqlMap resource="../../Maps/MySql/ByteFx/Account.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MySql_MySql.config Thu May 12 14:09:43 2005
@@ -16,9 +16,16 @@
<provider name="MySql"/>
<dataSource name="IBatisNet" connectionString="server=${datasourceMySql};user id=${userid}; password=${password}; database=${database}; pooling=false"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<!-- <sqlMap url="E:/Projet/IBatisNet/Source/IBatisNet.Test/Maps/MySql/ByteFx/Account.xml"/> ok -->
<sqlMap resource="../../Maps/MySql/MySql/Account.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_ODP.config Thu May 12 14:09:43 2005
@@ -16,9 +16,16 @@
<provider name="oracle10.1"/>
<dataSource name="iBatisNet" connectionString="Data Source=${datasource};User Id=${userid};Password=${password}"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<!-- <sqlMap url="E:/Projet/IBatisNet/Source/IBatisNet.Test/Maps/Oracle/ODP/Account.xml"/> ok -->
<sqlMap resource="../../Maps/Oracle/ODP/Account.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_Oracle_OracleClient.config Thu May 12 14:09:43 2005
@@ -16,9 +16,16 @@
<provider name="oracleClient1.0"/>
<dataSource name="iBatisNet" connectionString="Data Source=${datasource};User Id=${userid};Password=${password}"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
+ <typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
+ <typeHandlers>
+ <typeHandler type="bool" dbType="Bit" callback="OuiNonBool"/>
+ </typeHandlers>
+
<sqlMaps>
<!-- <sqlMap url="E:/Projet/IBatisNet/Source/IBatisNet.Test/Maps/Oracle/OracleClient/Account.xml"/> ok -->
<sqlMap resource="../../Maps/Oracle/OracleClient/Account.xml"/>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/CacheKey.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/CacheKey.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/CacheKey.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/CacheKey.cs Thu May 12 14:09:43 2005
@@ -24,15 +24,13 @@
********************************************************************************/
#endregion
-#region Imports
+#region Using
+
using System;
using System.Collections;
-using System.Xml.Serialization;
-using System.Reflection;
-
using IBatisNet.Common.Utilities.Objects;
-
using IBatisNet.DataMapper.TypeHandlers;
+
#endregion
@@ -42,7 +40,7 @@
/// Summary description for FlushInterval.
/// </summary>
[Serializable]
- public class CacheKey
+ internal class CacheKey
{
#region Fields
private string[] _properties = null;
@@ -52,6 +50,7 @@
private int _maxResults = 0 ;
private int _skipRecords = 0;
private CacheKeyType _type = CacheKeyType.Object;
+ private TypeHandlerFactory _typeHandlerFactory = null;
private string _hashCodeString = string.Empty;
private int _hashCode = 0;
@@ -67,9 +66,11 @@
/// <param name="skipRecords"></param>
/// <param name="maxResults"></param>
/// <param name="type"></param>
- public CacheKey(string statementName, string sql, object parameter, string[] properties,
+ /// <param name="typeHandlerFactory"></param>
+ internal CacheKey(TypeHandlerFactory typeHandlerFactory, string statementName, string sql, object parameter, string[] properties,
int skipRecords, int maxResults, CacheKeyType type)
{
+ _typeHandlerFactory = typeHandlerFactory;
_statementName = statementName;
_sql = sql;
_parameter = parameter;
@@ -78,7 +79,7 @@
_maxResults = maxResults;
_type = type;
_hashCode = GenerateHashCode();
- _hashCodeString = System.Convert.ToString(_hashCode);
+ _hashCodeString = Convert.ToString(_hashCode);
}
@@ -98,7 +99,7 @@
{
result = (_parameter != null ? _parameter.GetHashCode() : 0);
}
- else if ( _parameter != null && TypeHandlerFactory.IsSimpleType(_parameter.GetType()) )
+ else if ( _parameter != null && _typeHandlerFactory.IsSimpleType(_parameter.GetType()) )
{
result = (_parameter != null ? _parameter.GetHashCode() : 0);
}
@@ -135,7 +136,7 @@
if (_hashCode != cacheKey._hashCode) return false;
if (!_parameter.Equals(cacheKey._parameter)) return false;
}
- else if (_parameter != null && TypeHandlerFactory.IsSimpleType(_parameter.GetType()))
+ else if (_parameter != null && _typeHandlerFactory.IsSimpleType(_parameter.GetType()))
{
if (_parameter != null ? !_parameter.Equals(cacheKey._parameter) : cacheKey._parameter != null) return false;
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAlias.cs Thu May 12 14:09:43 2005
@@ -24,21 +24,18 @@
********************************************************************************/
#endregion
-#region Imports
+#region Using
+
using System;
-using System.IO;
-using System.Reflection;
-using System.Xml;
using System.Xml.Serialization;
-
-using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities;
+
#endregion
namespace IBatisNet.DataMapper.Configuration.Alias
{
/// <summary>
- /// Description résumée de TypeAlias.
+ /// TypeAlias.
/// </summary>
[Serializable]
[XmlRoot("typeAlias")]
@@ -51,7 +48,7 @@
[NonSerialized]
private string _className = string.Empty;
[NonSerialized]
- private Type _class;
+ private Type _class = null;
#endregion
#region Properties
@@ -77,7 +74,7 @@
/// <summary>
/// The type class for the typeAlias
/// </summary>
- [XmlIgnoreAttribute]
+ [XmlIgnore]
public Type Class
{
get { return _class; }
Added: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs?rev=169887&view=auto
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs (added)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs Thu May 12 14:09:43 2005
@@ -0,0 +1,122 @@
+
+#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.Xml.Serialization;
+using IBatisNet.Common.Utilities;
+
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.Alias
+{
+ /// <summary>
+ /// Summary description for TypeHandler.
+ /// </summary>
+ [Serializable]
+ [XmlRoot("typeHandler")]
+ public class TypeHandler
+ {
+ #region Fields
+ [NonSerialized]
+ private string _className = string.Empty;
+ [NonSerialized]
+ private Type _class = null;
+ [NonSerialized]
+ private string _dbType = string.Empty;
+ [NonSerialized]
+ private string _callBackName = string.Empty;
+ #endregion
+
+ #region Properties
+ /// <summary>
+ /// CLR type
+ /// </summary>
+ [XmlAttribute("type")]
+ public string ClassName
+ {
+ get { return _className; }
+ set {_className = value; }
+ }
+
+ /// <summary>
+ /// The type class for the TypeName
+ /// </summary>
+ [XmlIgnore]
+ public Type Class
+ {
+ get { return _class; }
+ }
+
+ /// <summary>
+ /// dbType name
+ /// </summary>
+ [XmlAttribute("dbType")]
+ public string DbType
+ {
+ get { return _dbType; }
+ set {_dbType = value; }
+ }
+
+
+ /// <summary>
+ /// callback alias name
+ /// </summary>
+ [XmlAttribute("callback")]
+ public string CallBackName
+ {
+ get { return _callBackName; }
+ set {_callBackName = value; }
+ }
+
+
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Do not use direclty, only for serialization.
+ /// </summary>
+ [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)]
+ public TypeHandler()
+ {}
+ #endregion
+
+
+ #region Methods
+ /// <summary>
+ /// Initialize the object,
+ /// try to idenfify the .Net type class from the corresponding name.
+ /// </summary>
+ public void Initialize()
+ {
+ _class = Resources.TypeForName(_className);
+ }
+ #endregion
+
+ }
+}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Thu May 12 14:09:43 2005
@@ -49,6 +49,7 @@
using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.MappedStatements;
using IBatisNet.DataMapper.Scope;
+using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -250,8 +251,8 @@
private void Initialize()
{
Reset();
-
- _configScope.SqlMapper = new SqlMapper();
+
+ _configScope.SqlMapper = new SqlMapper( new TypeHandlerFactory() );
#region Load settings
@@ -370,6 +371,56 @@
_configScope.ErrorContext.Reset();
#endregion
+ #region Load TypeHandlers
+ foreach (XmlNode xmlNode in _configScope.SqlMapConfigDocument.SelectNodes("/sqlMapConfig/typeHandlers/typeHandler"))
+ {
+ try
+ {
+ _configScope.ErrorContext.Activity = "loading typeHandler";
+ TypeHandler handler = null;
+ XmlSerializer serializer = new XmlSerializer(typeof(TypeHandler));
+
+ handler = (TypeHandler) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ _configScope.ErrorContext.ObjectId = handler.ClassName;
+ _configScope.ErrorContext.MoreInfo = "initialize typeHandler";
+ handler.Initialize();
+
+
+ _configScope.ErrorContext.MoreInfo = "Check the callback attribute '" + handler.ClassName + "' (must be a classname).";
+ ITypeHandler typeHandler = null;
+ Type type = _configScope.SqlMapper.GetType(handler.CallBackName);
+ object impl = Activator.CreateInstance( type );
+ if (impl is ITypeHandlerCallback)
+ {
+ typeHandler = new CustomTypeHandler((ITypeHandlerCallback) impl);
+ }
+ else if (impl is ITypeHandler)
+ {
+ typeHandler = (ITypeHandler) impl;
+ }
+ else
+ {
+ throw new ConfigurationException("The callBack type is not a valid implementation of ITypeHandler or ITypeHandlerCallback");
+ }
+
+ _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.Length > 0)
+ {
+ _configScope.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), handler.DbType, typeHandler);
+ }
+ else
+ {
+ _configScope.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), typeHandler);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Error registering occurred. Cause: " + e.Message, e);
+ }
+ }
+ _configScope.ErrorContext.Reset();
+ #endregion
+
#region Load sqlMap mapping files
foreach (XmlNode xmlNode in _configScope.SqlMapConfigDocument.SelectNodes("/sqlMapConfig/sqlMaps/sqlMap"))
@@ -895,7 +946,7 @@
{
bool isDynamic = false;
XmlNode commandTextNode = _configScope.NodeContext;
- DynamicSql dynamic = new DynamicSql(statement);
+ DynamicSql dynamic = new DynamicSql(_configScope.TypeHandlerFactory, statement);
StringBuilder sqlBuffer = new StringBuilder();
_configScope.ErrorContext.MoreInfo = "process the Sql statement";
@@ -961,7 +1012,7 @@
}
else
{
- sqlText = _paramParser.ParseInlineParameterMap( null, data );
+ sqlText = _paramParser.ParseInlineParameterMap(_configScope.TypeHandlerFactory, null, data );
}
dynamic.AddChild(sqlText);
@@ -1012,7 +1063,7 @@
// Build a Parametermap with the inline parameters.
// if they exist. Then delete inline infos from sqltext.
- SqlText sqlText = _paramParser.ParseInlineParameterMap( statement, newSql );
+ SqlText sqlText = _paramParser.ParseInlineParameterMap(_configScope.TypeHandlerFactory, statement, newSql );
if (sqlText.Parameters.Length > 0)
{
@@ -1032,7 +1083,7 @@
if (SimpleDynamicSql.IsSimpleDynamicSql(newSql))
{
- sql = new SimpleDynamicSql(newSql, statement);
+ sql = new SimpleDynamicSql(_configScope.TypeHandlerFactory, newSql, statement);
}
else
{
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/InlineParameterMapParser.cs Thu May 12 14:09:43 2005
@@ -76,7 +76,8 @@
/// <param name="statement"></param>
/// <param name="sqlStatement"></param>
/// <returns>A new sql command text.</returns>
- public SqlText ParseInlineParameterMap(IStatement statement, string sqlStatement)
+ /// <param name="typeHandlerFactory"></param>
+ public SqlText ParseInlineParameterMap(TypeHandlerFactory typeHandlerFactory, IStatement statement, string sqlStatement)
{
string newSql = sqlStatement;
ArrayList mappingList = new ArrayList();
@@ -109,7 +110,7 @@
else
{
//ParameterMapping mapping = null; Java
- ParameterProperty mapping = ParseMapping(token, parameterClass);
+ ParameterProperty mapping = ParseMapping(token, parameterClass, typeHandlerFactory);
mappingList.Add(mapping);
newSqlBuffer.Append("? ");
@@ -146,7 +147,7 @@
}
- private ParameterProperty ParseMapping(string token, Type parameterClass)
+ private ParameterProperty ParseMapping(string token, Type parameterClass, TypeHandlerFactory typeHandlerFactory)
{
ParameterProperty mapping = new ParameterProperty();
@@ -170,16 +171,14 @@
ITypeHandler handler = null;
if (parameterClass == null)
{
- handler = null; //TypeHandlerFactory.getUnkownTypeHandler();
+ handler = typeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(parameterClass, propertyName, null, null);
- //TypeHandlerFactory.GetTypeHandler(parameterClass);
- //
+ handler = ResolveTypeHandler(typeHandlerFactory, parameterClass, propertyName, null, null);
}
mapping.TypeHandler = handler;
- mapping.Initialize(_errorContext);
+ mapping.Initialize(typeHandlerFactory, _errorContext);
}
else if (n1 >= 5)
{
@@ -202,16 +201,14 @@
ITypeHandler handler;
if (parameterClass == null)
{
- handler = null;//TypeHandlerFactory.getUnkownTypeHandler();
+ handler = typeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(parameterClass, propertyName, null, null);
- //TypeHandlerFactory.GetTypeHandler(parameterClass);
- //
+ handler = ResolveTypeHandler(typeHandlerFactory, parameterClass, propertyName, null, null);
}
mapping.TypeHandler = handler;
- mapping.Initialize(_errorContext);
+ mapping.Initialize(typeHandlerFactory, _errorContext);
}
else
{
@@ -224,16 +221,14 @@
ITypeHandler handler;
if (parameterClass == null)
{
- handler = null;
- //TypeHandlerFactory.getUnkownTypeHandler();
+ handler = typeHandlerFactory.GetUnkownTypeHandler();
}
else
{
- handler = ResolveTypeHandler(parameterClass, token, null, null);
- //TypeHandlerFactory.GetTypeHandler(parameterClass);
+ handler = ResolveTypeHandler(typeHandlerFactory, parameterClass, token, null, null);
}
mapping.TypeHandler = handler;
- mapping.Initialize(_errorContext);
+ mapping.Initialize(typeHandlerFactory, _errorContext);
}
return mapping;
}
@@ -246,28 +241,30 @@
/// <param name="propertyName"></param>
/// <param name="propertyType"></param>
/// <param name="dbType"></param>
+ /// <param name="typeHandlerFactory"></param>
/// <returns></returns>
- private static ITypeHandler ResolveTypeHandler(Type type, string propertyName,
+ private ITypeHandler ResolveTypeHandler(TypeHandlerFactory typeHandlerFactory,
+ Type type, string propertyName,
string propertyType, string dbType)
{
ITypeHandler handler = null;
if (type == null)
{
- handler = null;//TypeHandlerFactory.getUnkownTypeHandler();
+ handler = typeHandlerFactory.GetUnkownTypeHandler();
}
else if (typeof(IDictionary).IsAssignableFrom(type))//java.util.Map.class.isAssignableFrom(clazz))
{
if (propertyType == null)
{
- handler = TypeHandlerFactory.GetTypeHandler(typeof(object), dbType);
+ handler = typeHandlerFactory.GetTypeHandler(typeof(object), dbType);
}
else
{
try
{
Type typeClass = Resources.TypeForName( propertyType );
- handler = TypeHandlerFactory.GetTypeHandler(typeClass, dbType);
+ handler = typeHandlerFactory.GetTypeHandler(typeClass, dbType);
}
catch (Exception e)
{
@@ -275,14 +272,14 @@
}
}
}
- else if (TypeHandlerFactory.GetTypeHandler(type, dbType) != null)
+ else if (typeHandlerFactory.GetTypeHandler(type, dbType) != null)
{
- handler = TypeHandlerFactory.GetTypeHandler(type, dbType);
+ handler = typeHandlerFactory.GetTypeHandler(type, dbType);
}
else
{
Type typeClass = ObjectProbe.GetPropertyTypeForGetter(type, propertyName);
- handler = TypeHandlerFactory.GetTypeHandler(typeClass, dbType);
+ handler = typeHandlerFactory.GetTypeHandler(typeClass, dbType);
}
return handler;
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Thu May 12 14:09:43 2005
@@ -271,22 +271,22 @@
{
if (this.CLRType.Length == 0 ) // Unknown
{
- _typeHandler = TypeHandlerFactory.GetUnkownTypeHandler();
+ _typeHandler = configScope.TypeHandlerFactory.GetUnkownTypeHandler();
}
else // If we specify a CLR type, use it
{
Type type = Resources.TypeForName(this.CLRType);
- if (TypeHandlerFactory.IsSimpleType(type))
+ if (configScope.TypeHandlerFactory.IsSimpleType(type))
{
// Primitive
- _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type);
}
else
{
// .NET object
type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
- _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(type);
}
}
}
@@ -297,7 +297,8 @@
///
/// </summary>
/// <param name="errorContext"></param>
- public void Initialize(ErrorContext errorContext)
+ /// <param name="typeHandlerFactory"></param>
+ internal void Initialize(TypeHandlerFactory typeHandlerFactory, ErrorContext errorContext)
{
if(_directionAttribute.Length >0)
{
@@ -307,22 +308,22 @@
errorContext.MoreInfo = "Intialize an inline parameter property '" + this.PropertyName + "' .";
if (this.CLRType.Length == 0 ) // Unknown
{
- _typeHandler = TypeHandlerFactory.GetUnkownTypeHandler();
+ _typeHandler = typeHandlerFactory.GetUnkownTypeHandler();
}
else // If we specify a CLR type, use it
{
Type type = Resources.TypeForName(this.CLRType);
- if (TypeHandlerFactory.IsSimpleType(type))
+ if (typeHandlerFactory.IsSimpleType(type))
{
// Primitive
- _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(type);
}
else
{
// .NET object
type = ObjectProbe.GetPropertyTypeForGetter(type, this.PropertyName);
- _typeHandler = TypeHandlerFactory.GetTypeHandler(type);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(type);
}
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs Thu May 12 14:09:43 2005
@@ -259,12 +259,12 @@
if ( propertyInfo != null)
{
- _typeHandler = TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
}
// If we specify a type, it can overrride
if (this.CLRType.Length>0)
{
- _typeHandler = TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
+ _typeHandler = configScope.TypeHandlerFactory.GetTypeHandler(Resources.TypeForName(this.CLRType));
}
// If we specify a typeHandler, it can overrride
if (this.CallBackName.Length >0)
@@ -288,11 +288,12 @@
/// for AutoMapper
/// </summary>
/// <param name="propertyInfo">A PropertyInfoot.</param>
- public void Initialize( PropertyInfo propertyInfo )
+ /// <param name="typeHandlerFactory"></param>
+ internal void Initialize(TypeHandlerFactory typeHandlerFactory, PropertyInfo propertyInfo )
{
_propertyInfo = propertyInfo;
- _typeHandler = TypeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
+ _typeHandler = typeHandlerFactory.GetTypeHandler(propertyInfo.PropertyType);
}
#endregion
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs Thu May 12 14:09:43 2005
@@ -37,6 +37,8 @@
using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Handlers;
using IBatisNet.DataMapper.Scope;
+using IBatisNet.DataMapper.TypeHandlers;
+
#endregion
namespace IBatisNet.DataMapper.Configuration.Sql.Dynamic
@@ -47,14 +49,15 @@
/// <example>
/// <dynamic prepend="where">...</dynamic>
/// </example>
- public class DynamicSql : ISql, IDynamicParent
+ internal class DynamicSql : ISql, IDynamicParent
{
#region Fields
private IList _children = new ArrayList();
private IStatement _statement = null ;
- InlineParameterMapParser _paramParser = null;
+ private InlineParameterMapParser _paramParser = null;
+ private TypeHandlerFactory _typeHandlerFactory = null;
#endregion
@@ -63,9 +66,11 @@
/// Constructor
/// </summary>
/// <param name="statement">The mapped statement.</param>
- public DynamicSql(IStatement statement)
+ /// <param name="typeHandlerFactory"></param>
+ internal DynamicSql(TypeHandlerFactory typeHandlerFactory, IStatement statement)
{
_statement = statement;
+ _typeHandlerFactory = typeHandlerFactory;
}
#endregion
@@ -137,7 +142,7 @@
// Processes $substitutions$ after DynamicSql
if ( SimpleDynamicSql.IsSimpleDynamicSql(dynSql) )
{
- dynSql = new SimpleDynamicSql(dynSql, _statement).GetSql(parameterObject);
+ dynSql = new SimpleDynamicSql(_typeHandlerFactory, dynSql, _statement).GetSql(parameterObject);
}
return dynSql;
}
@@ -244,7 +249,7 @@
if (handler.IsPostParseRequired)
{
- SqlText sqlText = _paramParser.ParseInlineParameterMap( null, body.ToString() );
+ SqlText sqlText = _paramParser.ParseInlineParameterMap(_typeHandlerFactory, null, body.ToString() );
buffer.Append(sqlText.Text);
ParameterProperty[] mappings = sqlText.Parameters;
if (mappings != null)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/SimpleDynamic/SimpleDynamicSql.cs Thu May 12 14:09:43 2005
@@ -45,15 +45,16 @@
/// <summary>
/// Summary description for SimpleDynamicSql.
/// </summary>
- public class SimpleDynamicSql : ISql
+ internal class SimpleDynamicSql : ISql
{
#region private
- private static readonly string ELEMENT_TOKEN = "$";
+ private const string ELEMENT_TOKEN = "$";
private string _simpleSqlStatement = string.Empty;
private IStatement _statement = null ;
+ private TypeHandlerFactory _typeHandlerFactory = null;
#endregion
@@ -63,10 +64,12 @@
/// </summary>
/// <param name="sqlStatement">The sql statement.</param>
/// <param name="statement"></param>
- public SimpleDynamicSql(string sqlStatement, IStatement statement)
+ /// <param name="typeHandlerFactory"></param>
+ internal SimpleDynamicSql(TypeHandlerFactory typeHandlerFactory,string sqlStatement, IStatement statement)
{
_simpleSqlStatement = sqlStatement;
_statement = statement;
+ _typeHandlerFactory = typeHandlerFactory;
}
#endregion
@@ -127,7 +130,7 @@
object value = null;
if (parameterObject != null)
{
- if ( TypeHandlerFactory.IsSimpleType( parameterObject.GetType() ) == true)
+ if ( _typeHandlerFactory.IsSimpleType( parameterObject.GetType() ) == true)
{
value = parameterObject;
}
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=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Thu May 12 14:09:43 2005
@@ -216,6 +216,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Configuration\Alias\TypeHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Configuration\Cache\CacheModel.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Thu May 12 14:09:43 2005
@@ -379,7 +379,7 @@
if (request.ResultMap != null)
{
request.SetResultMap(reader);
- ResultMap resultMap = request.ResultMap;
+ //ResultMap resultMap = request.ResultMap;
if (outObject == null)
{
@@ -404,13 +404,13 @@
}
// Check if the ResultClass is a 'primitive' Type
- if (TypeHandlerFactory.IsSimpleType(_statement.ResultClass))
+ if (_sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass))
{
// Create a ResultProperty
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = 0;
- property.TypeHandler = TypeHandlerFactory.GetTypeHandler(outObject.GetType());
+ property.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(outObject.GetType());
SetObjectProperty(request, request.ResultMap, property, ref outObject, reader);
}
@@ -471,7 +471,7 @@
{
Type propertyType =ObjectProbe.GetPropertyTypeForGetter(result,mapping.PropertyName);
- mapping.TypeHandler = TypeHandlerFactory.GetTypeHandler(propertyType);
+ mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(propertyType);
}
}
}
@@ -521,7 +521,7 @@
CacheKey key = null;
if (_statement.ParameterMap != null)
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
request.ParameterMap.GetPropertyNameArray(),
@@ -531,7 +531,7 @@
}
else
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
new string[0],
@@ -648,7 +648,7 @@
CacheKey key = null;
if (_statement.ParameterMap != null)
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
request.ParameterMap.GetPropertyNameArray(),
@@ -658,7 +658,7 @@
}
else
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
new string[0],
@@ -759,7 +759,6 @@
/// <param name="resultObject">A strongly typed collection of result objects.</param>
public virtual void ExecuteQueryForList(IDalSession session, object parameterObject, IList resultObject )
{
- IList result = new ArrayList();
RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
//using ( IDbCommand command = CreatePreparedCommand(request, session, parameterObject ) )
@@ -851,9 +850,9 @@
{
generatedKey = command.ExecuteScalar();
if ( (_statement.ResultClass!=null) &&
- TypeHandlerFactory.IsSimpleType(_statement.ResultClass) )
+ _sqlMap.TypeHandlerFactory.IsSimpleType(_statement.ResultClass) )
{
- ITypeHandler typeHandler = TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
+ ITypeHandler typeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(_statement.ResultClass);
generatedKey = typeHandler.GetDataBaseValue(generatedKey, _statement.ResultClass);
}
}
@@ -915,7 +914,7 @@
CacheKey key = null;
if (_statement.ParameterMap != null)
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
request.ParameterMap.GetPropertyNameArray(),
@@ -925,7 +924,7 @@
}
else
{
- key = new CacheKey(this.Name,
+ key = new CacheKey(_sqlMap.TypeHandlerFactory, this.Name,
request.PreparedStatement.PreparedSql,
parameterObject,
new string[0],
@@ -1068,7 +1067,7 @@
}
Type systemType =((IDataRecord)reader).GetFieldType(columnIndex);
- mapping.TypeHandler = TypeHandlerFactory.GetTypeHandler(systemType);
+ mapping.TypeHandler = _sqlMap.TypeHandlerFactory.GetTypeHandler(systemType);
}
}
}
@@ -1271,7 +1270,7 @@
{
if (_readerAutoMapper == null)
{
- _readerAutoMapper = new ReaderAutoMapper( reader, ref resultObject);
+ _readerAutoMapper = new ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
}
}
}
@@ -1290,7 +1289,8 @@
/// </summary>
/// <param name="reader"></param>
/// <param name="resultObject"></param>
- public ReaderAutoMapper(IDataReader reader,ref object resultObject)
+ /// <param name="typeHandlerFactory"></param>
+ public ReaderAutoMapper(TypeHandlerFactory typeHandlerFactory, IDataReader reader,ref object resultObject)
{
try
{
@@ -1318,7 +1318,7 @@
if (matchedPropertyInfo != null )
{
property.PropertyName = matchedPropertyInfo.Name;
- property.Initialize( matchedPropertyInfo );
+ property.Initialize(typeHandlerFactory, matchedPropertyInfo );
mappings.Add(property);
}
else if (resultObject is Hashtable)
@@ -1329,7 +1329,7 @@
// Set TypeHandler
Type propertyType = reflectionInfo.GetSetterType(property.PropertyName);
- property.TypeHandler = TypeHandlerFactory.GetTypeHandler( propertyType );
+ property.TypeHandler = typeHandlerFactory.GetTypeHandler( propertyType );
}
}
catch (Exception e)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Thu May 12 14:09:43 2005
@@ -29,6 +29,7 @@
using System.Collections.Specialized;
using System.Xml;
using IBatisNet.Common;
+using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -136,6 +137,17 @@
get
{
return _sqlMapper;
+ }
+ }
+
+ /// <summary>
+ /// The current TypeHandlerFactory
+ /// </summary>
+ internal TypeHandlerFactory TypeHandlerFactory
+ {
+ get
+ {
+ return _sqlMapper.TypeHandlerFactory;
}
}
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd Thu May 12 14:09:43 2005
@@ -1,9 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" >
+ <xs:element name="typeHandlers">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="typeHandler" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="alias">
<xs:complexType>
<xs:sequence>
- <xs:element ref="typeAlias"/>
+ <xs:element ref="typeAlias" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -62,6 +69,7 @@
<xs:element ref="properties" minOccurs="0" maxOccurs="1"/>
<xs:element ref="database" minOccurs="0" maxOccurs="1"/>
<xs:element ref="alias" minOccurs="0" maxOccurs="1"/>
+ <xs:element ref="typeHandlers" minOccurs="0" maxOccurs="1"/>
<xs:element ref="sqlMaps" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
@@ -77,6 +85,13 @@
<xs:complexType>
<xs:attribute name="alias" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="typeHandler">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="dbType" type="xs:string"/>
+ <xs:attribute name="callback" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Thu May 12 14:09:43 2005
@@ -46,6 +46,7 @@
using IBatisNet.DataMapper.Configuration.Cache;
using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -79,6 +80,7 @@
private HybridDictionary _typeAliasMaps = new HybridDictionary();
//(CacheModel name, cache))
private HybridDictionary _cacheMaps = new HybridDictionary();
+ private TypeHandlerFactory _typeHandlerFactory = null;
private bool _cacheModelsEnabled = false;
private bool _useEmbedStatementParams = false;
@@ -128,21 +130,30 @@
{
get { return _useEmbedStatementParams; }
}
+
+ /// <summary>
+ /// The TypeHandlerFactory
+ /// </summary>
+ internal TypeHandlerFactory TypeHandlerFactory
+ {
+ get { return _typeHandlerFactory; }
+ }
#endregion
#region Constructor (s) / Destructor
/// <summary>
/// Create a new SqlMap
/// </summary>
- internal SqlMapper()
+ internal SqlMapper(TypeHandlerFactory typeHandlerFactory)
{
+ _typeHandlerFactory = typeHandlerFactory;
_sessionContainer = SessionContainerFactory.GetSessionContainer(IBatisNet.Common.Utilities.HashCodeProvider.GetIdentityHashCode(this).ToString());
}
#endregion
#region Methods
/// <summary>
- /// Set the faleg to tell us if cache models were enabled
+ /// Set the falg to tell us if cache models were enabled
/// or not.
/// </summary>
internal void SetCacheModelsEnabled(bool value)
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs Thu May 12 14:09:43 2005
@@ -41,7 +41,9 @@
#region Fields
- private static readonly HybridDictionary _typeHandlerMap = new HybridDictionary();
+ private HybridDictionary _typeHandlerMap = new HybridDictionary();
+ private ITypeHandler _unknownTypeHandler = null;
+ private const string NULL = "_NULL_TYPE_";
#endregion
@@ -50,57 +52,59 @@
/// <summary>
/// Constructor
/// </summary>
- static TypeHandlerFactory()
+ public TypeHandlerFactory()
{
- ITypeHandler handler;
+ ITypeHandler handler = null;
handler = new BooleanTypeHandler();
- _typeHandlerMap.Add(typeof(bool), handler); // key= "System.Boolean"
+ this.Register(typeof(bool), handler); // key= "System.Boolean"
handler = new ByteTypeHandler();
- _typeHandlerMap.Add(typeof(Byte), handler);
+ this.Register(typeof(Byte), handler);
handler = new CharTypeHandler();
- _typeHandlerMap.Add(typeof(Char), handler);
+ this.Register(typeof(Char), handler);
handler = new DateTimeTypeHandler();
- _typeHandlerMap.Add(typeof(DateTime), handler);
+ this.Register(typeof(DateTime), handler);
handler = new DecimalTypeHandler();
- _typeHandlerMap.Add(typeof(Decimal), handler);
+ this.Register(typeof(Decimal), handler);
handler = new DoubleTypeHandler();
- _typeHandlerMap.Add(typeof(Double), handler);
+ this.Register(typeof(Double), handler);
handler = new Int16TypeHandler();
- _typeHandlerMap.Add(typeof(Int16), handler);
+ this.Register(typeof(Int16), handler);
handler = new Int32TypeHandler();
- _typeHandlerMap.Add(typeof(Int32), handler);
+ this.Register(typeof(Int32), handler);
handler = new Int64TypeHandler();
- _typeHandlerMap.Add(typeof(Int64), handler);
+ this.Register(typeof(Int64), handler);
handler = new SingleTypeHandler();
- _typeHandlerMap.Add(typeof(Single), handler);
+ this.Register(typeof(Single), handler);
handler = new StringTypeHandler();
- _typeHandlerMap.Add(typeof(String), handler);
+ this.Register(typeof(String), handler);
handler = new GuidTypeHandler();
- _typeHandlerMap.Add(typeof(Guid), handler);
+ this.Register(typeof(Guid), handler);
handler = new TimeSpanTypeHandler();
- _typeHandlerMap.Add(typeof(TimeSpan), handler);
+ this.Register(typeof(TimeSpan), handler);
handler = new ByteArrayTypeHandler();
- _typeHandlerMap.Add(typeof(Byte[]), handler);
+ this.Register(typeof(Byte[]), handler);
handler = new ObjectTypeHandler();
- _typeHandlerMap.Add(typeof(object), handler);
+ this.Register(typeof(object), handler);
handler = new EnumTypeHandler();
- _typeHandlerMap.Add( typeof(System.Enum), handler);
+ this.Register( typeof(System.Enum), handler);
+
+ _unknownTypeHandler = new UnknownTypeHandler(this);
}
@@ -109,41 +113,96 @@
#region Methods
/// <summary>
- ///
+ /// Get a TypeHandler for a type
/// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public static ITypeHandler GetTypeHandler(Type type)
+ /// <param name="type">the type you want a TypeHandler for</param>
+ /// <returns>the handler</returns>
+ public ITypeHandler GetTypeHandler(Type type)
{
if (type.IsEnum)
{
- return (ITypeHandler) _typeHandlerMap[typeof(System.Enum)];
+ return this.GetTypeHandler(typeof(System.Enum), null);
}
else
{
- return (ITypeHandler) _typeHandlerMap[type];
+ return this.GetTypeHandler(type, null);
}
}
/// <summary>
- /// Get a TypeHandler for a type
+ /// Get a TypeHandler for a type and a dbType type
/// </summary>
- /// <param name="type"></param>
- /// <param name="dbType"></param>
- /// <returns></returns>
- public static ITypeHandler GetTypeHandler(Type type, string dbType)
+ /// <param name="type">the type</param>
+ /// <param name="dbType">the dbType type</param>
+ /// <returns>the handler</returns>
+ public ITypeHandler GetTypeHandler(Type type, string dbType)
+ {
+ HybridDictionary dbTypeHandlerMap = (HybridDictionary) _typeHandlerMap[ type ];
+ ITypeHandler handler = null;
+
+ if (dbTypeHandlerMap != null)
+ {
+ if (dbType==null)
+ {
+ handler = (ITypeHandler) dbTypeHandlerMap[ NULL ];
+ }
+ else
+ {
+ handler = (ITypeHandler) dbTypeHandlerMap[ dbType ];
+ if (handler == null)
+ {
+ handler = (ITypeHandler) dbTypeHandlerMap[ NULL ];
+ }
+ }
+
+ }
+ return handler;
+
+ //return GetTypeHandler(type);
+ }
+
+
+ /// <summary>
+ /// Register (add) a type handler for a type
+ /// </summary>
+ /// <param name="type">the type</param>
+ /// <param name="handler">the handler instance</param>
+ public void Register(Type type, ITypeHandler handler)
{
- return GetTypeHandler(type);
+ this.Register(type, null, handler);
}
+ /// <summary>
+ /// Register (add) a type handler for a type and dbType
+ /// </summary>
+ /// <param name="type">the type</param>
+ /// <param name="dbType">the dbType</param>
+ /// <param name="handler">the handler instance</param>
+ public void Register(Type type, string dbType, ITypeHandler handler)
+ {
+ HybridDictionary map = (HybridDictionary) _typeHandlerMap[ type ];
+ if (map == null)
+ {
+ map = new HybridDictionary();
+ _typeHandlerMap.Add(type, map) ;
+ }
+ if (dbType==null)
+ {
+ map.Add(NULL, handler);
+ }
+ else
+ {
+ map.Add(dbType, handler);
+ }
+ }
/// <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()
+ public ITypeHandler GetUnkownTypeHandler()
{
- return new UnknownTypeHandler();
+ return _unknownTypeHandler;
}
/// <summary>
@@ -151,12 +210,12 @@
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
- public static bool IsSimpleType(Type type)
+ public bool IsSimpleType(Type type)
{
bool result = false;
if (type != null)
{
- ITypeHandler handler = TypeHandlerFactory.GetTypeHandler(type);
+ ITypeHandler handler = this.GetTypeHandler(type);
if (handler != null)
{
result = handler.IsSimpleType();
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs?rev=169887&r1=169886&r2=169887&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/UnknownTypeHandler.cs Thu May 12 14:09:43 2005
@@ -40,6 +40,16 @@
internal class UnknownTypeHandler : BaseTypeHandler
{
+ private TypeHandlerFactory _factory = null;
+
+ /// <summary>
+ /// Constructor to create via a factory
+ /// </summary>
+ /// <param name="factory">the factory to associate this with</param>
+ public UnknownTypeHandler(TypeHandlerFactory factory)
+ {
+ _factory = factory;
+ }
/// <summary>
/// Performs processing on a value before it is used to set
/// the parameter of a IDbCommand.
@@ -51,7 +61,7 @@
{
if (parameterValue!=null)
{
- ITypeHandler handler = TypeHandlerFactory.GetTypeHandler( parameterValue.GetType() );
+ ITypeHandler handler = _factory.GetTypeHandler( parameterValue.GetType() );
handler.SetParameter(mapping, dataParameter, parameterValue);
}
else