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/06/21 18:40:28 UTC
svn commit: r416031 - in /ibatis/trunk/cs/mapper:
IBatisNet.Common.Test/Domain/
IBatisNet.Common.Test/NUnit/CommonTests/Utilities/
IBatisNet.Common/Utilities/Objects/
IBatisNet.Common/Utilities/Objects/Members/
IBatisNet.DataMapper/Configuration/Parame...
Author: gbayon
Date: Wed Jun 21 09:40:27 2006
New Revision: 416031
URL: http://svn.apache.org/viewvc?rev=416031&view=rev
Log:
- Refactor complex result property process
- Fixed issue on DelegateFactory
- Fixed issue on object factory when no match constructor exists
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Item.cs
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/DelegateFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/FactoryBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/GetAccessorFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Item.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Item.cs?rev=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Item.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Item.cs Wed Jun 21 09:40:27 2006
@@ -11,4 +11,11 @@
{
}
}
+
+ public class ItemBis
+ {
+ public ItemBis(string description)
+ {
+ }
+ }
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs?rev=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ObjectFactoryTest.cs Wed Jun 21 09:40:27 2006
@@ -42,6 +42,17 @@
object obj = factory.CreateInstance(null);
}
+ [Test]
+ [ExpectedException(typeof(ProbeException))]
+ public void NoMatchConstructor()
+ {
+ IObjectFactory objectFactory = new ObjectFactory(true);
+
+ IFactory factory = objectFactory.CreateFactory(typeof(ItemBis), Type.EmptyTypes);
+
+ object obj = factory.CreateInstance(null);
+ }
+
[Test]
[ExpectedException(typeof(ProbeException))]
public void ProtectedConstructor()
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/DelegateFactory.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/DelegateFactory.cs?rev=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/DelegateFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/DelegateFactory.cs Wed Jun 21 09:40:27 2006
@@ -75,7 +75,7 @@
// Emit the IL for Create method.
// Add test if contructeur not public
ConstructorInfo constructorInfo = typeToCreate.GetConstructor(VISIBILITY, null, argumentTypes, null);
- if (!constructorInfo.IsPublic)
+ if (constructorInfo==null || !constructorInfo.IsPublic)
{
throw new ProbeException(
string.Format("Unable to optimize create instance. Cause : Could not find public constructor matching specified arguments for type \"{0}\".", typeToCreate.Name));
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/FactoryBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/FactoryBuilder.cs?rev=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/FactoryBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/FactoryBuilder.cs Wed Jun 21 09:40:27 2006
@@ -114,7 +114,7 @@
// Add test if contructeur not public
ConstructorInfo ctor = typeToCreate.GetConstructor(VISIBILITY, null, argumentTypes, null);
- if (!ctor.IsPublic)
+ if (ctor==null || !ctor.IsPublic)
{
throw new ProbeException(
string.Format("Unable to optimize create instance. Cause : Could not find public constructor matching specified arguments for type \"{0}\".", typeToCreate.Name));
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/GetAccessorFactory.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/GetAccessorFactory.cs?rev=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/GetAccessorFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/GetAccessorFactory.cs Wed Jun 21 09:40:27 2006
@@ -103,7 +103,7 @@
{
MethodInfo methodInfo = null;
#if dotnet2
- methodInfo = propertyInfo.GetSetMethod();
+ methodInfo = propertyInfo.GetGetMethod();
#else
methodInfo = targetType.GetMethod("get_" + propertyName);
#endif
@@ -162,7 +162,7 @@
{
MethodInfo methodInfo = null;
#if dotnet2
- methodInfo = propertyInfo.GetSetMethod();
+ methodInfo = propertyInfo.GetGetMethod();
#else
methodInfo = targetType.GetMethod("get_" + propertyName,BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
if (methodInfo == null)
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=416031&r1=416030&r2=416031&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Wed Jun 21 09:40:27 2006
@@ -301,11 +301,12 @@
}
else // complex member name FavouriteLineItem.Id
{
- MemberInfo propertyInfo = ObjectProbe.GetMemberInfoForSetter(parameterClass, _propertyName);
- string memberName = _propertyName.Substring( _propertyName.LastIndexOf('.')+1);
+ string memberName = _propertyName.Substring( _propertyName.LastIndexOf('.')+1);
+ string parentName = _propertyName.Substring(0,_propertyName.LastIndexOf('.'));
+ Type parentType = ObjectProbe.GetMemberTypeForGetter(parameterClass, parentName);
IGetAccessorFactory getAccessorFactory = scope.DataExchangeFactory.AccessorFactory.GetAccessorFactory;
- _getAccessor = getAccessorFactory.CreateGetAccessor(propertyInfo.ReflectedType, memberName);
+ _getAccessor = getAccessorFactory.CreateGetAccessor(parentType, memberName);
}
}