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/03/02 21:00:24 UTC
svn commit: r382490 - in /ibatis/trunk/cs/mapper: IBatisNet.Common.Test/
IBatisNet.Common.Test/NUnit/CommonTests/Utilities/
IBatisNet.Common/Utilities/TypesResolver/ IBatisNet.DataMapper.Test/
Author: gbayon
Date: Thu Mar 2 12:00:22 2006
New Revision: 382490
URL: http://svn.apache.org/viewcvs?rev=382490&view=rev
Log:
- Used Nunit 2.2.7
- Fixed IBATISNET-137
Added:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs (with props)
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj?rev=382490&r1=382489&r2=382490&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj Thu Mar 2 12:00:22 2006
@@ -132,6 +132,7 @@
<Compile Include="NUnit\CommonTests\Utilities\ResourcesTest.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="NUnit\CommonTests\Utilities\TypeResolverTest.cs" />
<None Include="bin\Debug\dao_Access_OleDb.config" />
<None Include="bin\Debug\dao_MSSQL_Odbc.config" />
<None Include="bin\Debug\dao_MSSQL_OleDb.config" />
Added: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs?rev=382490&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs Thu Mar 2 12:00:22 2006
@@ -0,0 +1,41 @@
+using System;
+using System.Text;
+using IBatisNet.Common.Utilities.TypesResolver;
+using NUnit.Framework;
+
+namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities
+{
+ [TestFixture]
+ public class TypeResolverTest
+ {
+ /// <summary>
+ /// Test nullable resolver
+ /// </summary>
+ [Test]
+ public void TestFullNameNullableType()
+ {
+ Type nullableType = typeof(bool?);
+
+ TypeResolver resolver = new TypeResolver();
+
+ Type nullableBooleanType = resolver.Resolve(nullableType.FullName);
+
+ Assert.IsNotNull(nullableBooleanType);
+ }
+
+ /// <summary>
+ /// Test nullable resolver
+ /// </summary>
+ [Test]
+ public void TestAssemblyQualifiedNameNullableType()
+ {
+ Type nullableType = typeof(bool?);
+
+ TypeResolver resolver = new TypeResolver();
+
+ Type nullableBooleanType = resolver.Resolve(nullableType.AssemblyQualifiedName);
+
+ Assert.IsNotNull(nullableBooleanType);
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/TypeResolverTest.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs?rev=382490&r1=382489&r2=382490&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypesResolver/TypeResolver.cs Thu Mar 2 12:00:22 2006
@@ -1,12 +1,14 @@
#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
@@ -133,24 +135,34 @@
/// from their attendant <see cref="System.Reflection.Assembly"/>
/// names in an assembly qualified type name.
/// </summary>
- public const string TypeAssemblySeparator = ",";
+ public const string TYPE_ASSEMBLY_SEPARATOR = ",";
+ public const string NULLABLE_TYPE = "System.Nullable";
+ public const string NULLABLE_TYPE_ASSEMBLY_SEPARATOR = "]],";
#endregion
#region Fields
- private string unresolvedAssemblyName;
- private string unresolvedTypeName;
+ private string _unresolvedAssemblyName = string.Empty;
+ private string _unresolvedTypeName = string.Empty;
+ private bool _isNullable = false;
+
#endregion
#region Properties
+
+ /// <summary>
+ /// Indicatre if the type is a nullable type.
+ /// </summary>
+ public bool IsNullable
+ {
+ get { return _isNullable; }
+ }
+
/// <summary>
/// The (unresolved) type name portion of the original type name.
/// </summary>
public string TypeName
{
- get
- {
- return unresolvedTypeName;
- }
+ get { return _unresolvedTypeName; }
}
/// <summary>
@@ -158,10 +170,7 @@
/// </summary>
public string AssemblyName
{
- get
- {
- return unresolvedAssemblyName;
- }
+ get { return _unresolvedAssemblyName; }
}
/// <summary>
@@ -189,11 +198,10 @@
{
get
{
- System.Text.StringBuilder buffer
- = new System.Text.StringBuilder (TypeName);
+ System.Text.StringBuilder buffer = new System.Text.StringBuilder (TypeName);
if (IsAssemblyQualified)
{
- buffer.Append (TypeAssemblySeparator);
+ buffer.Append(TYPE_ASSEMBLY_SEPARATOR);
buffer.Append (AssemblyName);
}
return buffer.ToString ();
@@ -218,20 +226,34 @@
#region Methods
private void SplitTypeAndAssemblyNames (string originalTypeName)
{
- int typeAssemblyIndex
- = originalTypeName.IndexOf (
- TypeAssemblyInfo.TypeAssemblySeparator);
- if (typeAssemblyIndex < 0)
- {
- unresolvedTypeName = originalTypeName;
- }
- else
- {
- unresolvedTypeName = originalTypeName.Substring (
- 0, typeAssemblyIndex).Trim ();
- unresolvedAssemblyName = originalTypeName.Substring (
- typeAssemblyIndex + 1).Trim ();
- }
+ if (originalTypeName.Contains(TypeAssemblyInfo.NULLABLE_TYPE))
+ {
+ _isNullable = true;
+ int typeAssemblyIndex = originalTypeName.IndexOf(TypeAssemblyInfo.NULLABLE_TYPE_ASSEMBLY_SEPARATOR);
+ if (typeAssemblyIndex < 0)
+ {
+ _unresolvedTypeName = originalTypeName;
+ }
+ else
+ {
+ _unresolvedTypeName = originalTypeName.Substring(0, typeAssemblyIndex + 2).Trim();
+ _unresolvedAssemblyName = originalTypeName.Substring(typeAssemblyIndex + 3).Trim();
+ }
+ }
+ else
+ {
+ int typeAssemblyIndex = originalTypeName.IndexOf(TypeAssemblyInfo.TYPE_ASSEMBLY_SEPARATOR);
+ _isNullable = false;
+ if (typeAssemblyIndex < 0)
+ {
+ _unresolvedTypeName = originalTypeName;
+ }
+ else
+ {
+ _unresolvedTypeName = originalTypeName.Substring(0, typeAssemblyIndex).Trim();
+ _unresolvedAssemblyName = originalTypeName.Substring(typeAssemblyIndex + 1).Trim();
+ }
+ }
}
#endregion
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj?rev=382490&r1=382489&r2=382490&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj Thu Mar 2 12:00:22 2006
@@ -78,7 +78,7 @@
<Name>log4net</Name>
<HintPath>..\External-Bin\Net\1.1\log4net.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.2.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="nunit.framework, Version=2.2.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System">
<Name>System</Name>
</Reference>