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/16 20:43:08 UTC
svn commit: r386438 - in /ibatis/trunk/cs/mapper: IBatisNet.Common.Test/
IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ IBatisNet.Common/
IBatisNet.Common/Utilities/Objects/
IBatisNet.Common/Utilities/Objects/Members/
Author: gbayon
Date: Thu Mar 16 11:42:57 2006
New Revision: 386438
URL: http://svn.apache.org/viewcvs?rev=386438&view=rev
Log:
- Changed IPropertyAccessor in IMemberAccessor (so future field mapping will be easiest)
Added:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs (with props)
Removed:
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ILPropertyAccessor.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/IPropertyAccessor.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/PropertyAccessorFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ReflectionPropertyAccessor.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorPerformance.cs
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.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=386438&r1=386437&r2=386438&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 16 11:42:57 2006
@@ -132,6 +132,7 @@
<Compile Include="NUnit\CommonTests\Transaction\TransactionTest.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="NUnit\CommonTests\Utilities\FieldAccessorTest.cs" />
<Compile Include="NUnit\CommonTests\Utilities\ObjectFactoryTest.cs" />
<Compile Include="NUnit\CommonTests\Utilities\PropertyAccessorPerformance.cs" />
<Compile Include="NUnit\CommonTests\Utilities\PropertyAccessorTest.cs" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj?rev=386438&r1=386437&r2=386438&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/IBatisNet.Common.Test.csproj Thu Mar 16 11:42:57 2006
@@ -295,6 +295,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "NUnit\CommonTests\Utilities\FieldAccessorTest.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "NUnit\CommonTests\Utilities\ObjectFactoryTest.cs"
SubType = "Code"
BuildAction = "Compile"
Added: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,17 @@
+using System;
+
+namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities
+{
+ /// <summary>
+ /// Summary description for FieldAccessorTest.
+ /// </summary>
+ public class FieldAccessorTest
+ {
+ public FieldAccessorTest()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/FieldAccessorTest.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorPerformance.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorPerformance.cs?rev=386438&r1=386437&r2=386438&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorPerformance.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorPerformance.cs Thu Mar 16 11:42:57 2006
@@ -3,6 +3,7 @@
using IBatisNet.Common.Test.Domain;
using IBatisNet.Common.Utilities;
using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.Common.Utilities.Objects.Members;
using NUnit.Framework;
@@ -62,8 +63,8 @@
GC.Collect();
GC.WaitForPendingFinalizers();
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Int");
timer.Start();
for (int i = 0; i < TEST_ITERATIONS; i++)
{
@@ -80,7 +81,7 @@
GC.Collect();
GC.WaitForPendingFinalizers();
- ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(prop.GetType());
+ ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(prop.GetType());
timer.Start();
for (int i = 0; i < TEST_ITERATIONS; i++)
{
@@ -133,7 +134,7 @@
// Print results
Console.WriteLine("{0} property gets on integer...", TEST_ITERATIONS);
Console.WriteLine("Direct access: \t\t{0} ", directAccessDuration.ToString("F3"));
- Console.WriteLine("IPropertyAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
+ Console.WriteLine("IMemberAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
Console.WriteLine("IBatisNet ReflectionInfo: \t{0} Ratio: {1}", reflectionInfoDuration.ToString("F3"), reflectionInfoRatio.ToString("F3"));
Console.WriteLine("ReflectionInvokeMember: \t{0} Ratio: {1}", reflectionInvokeMemberDuration.ToString("F3"), reflectionInvokeMemberRatio.ToString("F3"));
Console.WriteLine("Reflection: \t\t\t{0} Ratio: {1}", reflectionDuration.ToString("F3"), reflectionRatio.ToString("F3"));
@@ -168,8 +169,8 @@
GC.Collect();
GC.WaitForPendingFinalizers();
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Int");
timer.Start();
for (int i = 0; i < TEST_ITERATIONS; i++)
{
@@ -231,7 +232,7 @@
// Print results
Console.WriteLine("{0} property sets on integer...", TEST_ITERATIONS);
Console.WriteLine("Direct access: \t\t{0} ", directAccessDuration.ToString("F3"));
- Console.WriteLine("IPropertyAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
+ Console.WriteLine("IMemberAccessor: \t\t{0} Ratio: {1}", propertyAccessorDuration.ToString("F3"), propertyAccessorRatio.ToString("F3"));
Console.WriteLine("IBatisNet ReflectionInfo: \t{0} Ratio: {1}", reflectionInfoDuration.ToString("F3"), reflectionInfoRatio.ToString("F3"));
Console.WriteLine("ReflectionInvokeMember: \t{0} Ratio: {1}", reflectionInvokeMemberDuration.ToString("F3"), reflectionInvokeMemberRatio.ToString("F3"));
Console.WriteLine("Reflection: \t\t\t{0} Ratio: {1}", reflectionDuration.ToString("F3"), reflectionRatio.ToString("F3"));
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs?rev=386438&r1=386437&r2=386438&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs Thu Mar 16 11:42:57 2006
@@ -2,7 +2,7 @@
using System.Reflection;
using IBatisNet.Common.Test.Domain;
using IBatisNet.Common.Utilities;
-using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.Common.Utilities.Objects.Members;
using NUnit.Framework;
namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities
@@ -32,30 +32,30 @@
#endregion
/// <summary>
- /// Test PropertyAccessorFactory
+ /// Test MemberAccessorFactory
/// </summary>
[Test]
- public void TestPropertyAccessorFactory()
+ public void TestMemberAccessorFactory()
{
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor1 = factory.CreatePropertyAccessor(typeof(Property), "Int");
- IPropertyAccessor propertyAccessor2 = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor1 = factory.CreateMemberAccessor(typeof(Property), "Int");
+ IMemberAccessor propertyAccessor2 = factory.CreateMemberAccessor(typeof(Property), "Int");
Assert.AreEqual(HashCodeProvider.GetIdentityHashCode(propertyAccessor1), HashCodeProvider.GetIdentityHashCode(propertyAccessor2) );
}
/// <summary>
- /// Test multiple PropertyAccessorFactory
+ /// Test multiple MemberAccessorFactory
/// </summary>
[Test]
- public void TestMultiplePropertyAccessorFactory()
+ public void TestMultipleMemberAccessorFactory()
{
Property prop = new Property();
- PropertyAccessorFactory factory1 = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor1 = factory1.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory1 = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor1 = factory1.CreateMemberAccessor(typeof(Property), "Int");
- PropertyAccessorFactory factory2 = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor2 = factory2.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory2 = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor2 = factory2.CreateMemberAccessor(typeof(Property), "Int");
Assert.AreEqual(int.MinValue, propertyAccessor1.Get(prop));
Assert.AreEqual(int.MinValue, propertyAccessor2.Get(prop));
@@ -73,8 +73,8 @@
prop.Int = -99;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Int");
propertyAccessor.Set(prop, null);
Assert.AreEqual(0, prop.Int);
}
@@ -89,8 +89,8 @@
prop.Int = -99;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Int");
int test = 57;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Int);
@@ -107,8 +107,8 @@
prop.Int = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Int");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Int");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -123,8 +123,8 @@
prop.Long = 78945566664213223;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Long");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Long");
propertyAccessor.Set(prop, null);
Assert.AreEqual((long)0, prop.Long);
}
@@ -139,8 +139,8 @@
prop.Long = 78945566664213223;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Long");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Long");
long test = 123456789987456;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Long);
@@ -157,8 +157,8 @@
prop.Long = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Long");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Long");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -173,8 +173,8 @@
prop.SByte = 78;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "SByte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "SByte");
propertyAccessor.Set(prop, null);
Assert.AreEqual((sbyte)0, prop.SByte);
}
@@ -189,8 +189,8 @@
prop.SByte = 78;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "SByte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "SByte");
sbyte test = 19;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.SByte);
@@ -207,8 +207,8 @@
prop.SByte = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "SByte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "SByte");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -223,8 +223,8 @@
prop.String = "abc";
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "String");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "String");
propertyAccessor.Set(prop, null);
Assert.IsNull(prop.String);
}
@@ -239,8 +239,8 @@
prop.String = "abc";
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "String");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "String");
string test = "wxc";
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.String);
@@ -257,8 +257,8 @@
prop.String = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "String");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "String");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -276,8 +276,8 @@
// propertyInfo.SetValue(prop, null, null);
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "DateTime");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "DateTime");
propertyAccessor.Set(prop, null);
Assert.AreEqual(DateTime.MinValue, prop.DateTime);
}
@@ -292,8 +292,8 @@
prop.DateTime = DateTime.Now;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "DateTime");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "DateTime");
DateTime test = new DateTime(1987,11,25);
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.DateTime);
@@ -310,8 +310,8 @@
prop.DateTime = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "DateTime");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "DateTime");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -326,8 +326,8 @@
prop.Decimal = 45.187M;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Decimal");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Decimal");
propertyAccessor.Set(prop, null);
Assert.AreEqual(0.0M, prop.Decimal);
}
@@ -342,8 +342,8 @@
prop.Decimal = 45.187M;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Decimal");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Decimal");
Decimal test = 789456.141516M;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Decimal);
@@ -360,8 +360,8 @@
prop.Decimal = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Decimal");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Decimal");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -376,8 +376,8 @@
prop.Byte = 78;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Byte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Byte");
propertyAccessor.Set(prop, null);
Assert.AreEqual((byte)0, prop.Byte);
}
@@ -392,8 +392,8 @@
prop.Byte = 15;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Byte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Byte");
byte test = 94;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Byte);
@@ -410,8 +410,8 @@
prop.Byte = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Byte");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Byte");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -426,8 +426,8 @@
prop.Char = 'r';
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Char");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Char");
propertyAccessor.Set(prop, null);
Assert.AreEqual('\0', prop.Char);
}
@@ -442,8 +442,8 @@
prop.Char = 'b';
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Char");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Char");
char test = 'j';
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Char);
@@ -460,8 +460,8 @@
prop.Char = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Char");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Char");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -476,8 +476,8 @@
prop.Short = 5;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Short");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Short");
propertyAccessor.Set(prop, null);
Assert.AreEqual((short)0, prop.Short);
}
@@ -492,8 +492,8 @@
prop.Short = 9;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Short");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Short");
short test = 45;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Short);
@@ -510,8 +510,8 @@
prop.Short = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Short");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Short");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -526,8 +526,8 @@
prop.UShort = 5;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UShort");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UShort");
propertyAccessor.Set(prop, null);
Assert.AreEqual((ushort)0, prop.UShort);
}
@@ -542,8 +542,8 @@
prop.UShort = 9;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UShort");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UShort");
ushort test = 45;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.UShort);
@@ -560,8 +560,8 @@
prop.UShort = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UShort");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UShort");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -576,8 +576,8 @@
prop.UInt = 5;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UInt");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UInt");
propertyAccessor.Set(prop, null);
Assert.AreEqual((uint)0, prop.UInt);
}
@@ -592,8 +592,8 @@
prop.UInt = 9;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UInt");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UInt");
uint test = 45;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.UInt);
@@ -610,8 +610,8 @@
prop.UInt = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "UInt");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "UInt");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -626,8 +626,8 @@
prop.ULong = 5L;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "ULong");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "ULong");
propertyAccessor.Set(prop, null);
Assert.AreEqual((ulong)0, prop.ULong);
}
@@ -642,8 +642,8 @@
prop.ULong = 45464646578;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "ULong");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "ULong");
ulong test = 45;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.ULong);
@@ -660,8 +660,8 @@
prop.ULong = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "ULong");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "ULong");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -676,8 +676,8 @@
prop.Bool = true;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Bool");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Bool");
propertyAccessor.Set(prop, null);
Assert.AreEqual(false, prop.Bool);
}
@@ -692,8 +692,8 @@
prop.Bool = false;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Bool");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Bool");
bool test = true;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Bool);
@@ -710,8 +710,8 @@
prop.Bool = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Bool");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Bool");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -726,8 +726,8 @@
prop.Double = 788956.56D;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Double");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Double");
propertyAccessor.Set(prop, null);
Assert.AreEqual(0.0D, prop.Double);
}
@@ -742,8 +742,8 @@
prop.Double = 56789123.45888D;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Double");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Double");
double test = 788956.56D;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Double);
@@ -760,8 +760,8 @@
prop.Double = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Double");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Double");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -776,8 +776,8 @@
prop.Float = 565.45F;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Float");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Float");
propertyAccessor.Set(prop, null);
Assert.AreEqual(0.0D, prop.Float);
}
@@ -792,8 +792,8 @@
prop.Float = 565.45F;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Float");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Float");
float test = 4567.45F;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Float);
@@ -810,8 +810,8 @@
prop.Float = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Float");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Float");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -826,8 +826,8 @@
prop.Guid = Guid.NewGuid();
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Guid");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Guid");
propertyAccessor.Set(prop, null);
Assert.AreEqual(Guid.Empty, prop.Guid);
}
@@ -842,8 +842,8 @@
prop.Guid = Guid.NewGuid();
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Guid");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Guid");
Guid test = Guid.NewGuid();
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Guid);
@@ -860,8 +860,8 @@
prop.Guid = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Guid");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Guid");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -876,8 +876,8 @@
prop.TimeSpan = new TimeSpan(5,12,57,21,13) ;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "TimeSpan");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "TimeSpan");
propertyAccessor.Set(prop, null);
Assert.AreEqual(TimeSpan.MinValue, prop.TimeSpan);
}
@@ -892,8 +892,8 @@
prop.TimeSpan = new TimeSpan(5,12,57,21,13) ;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "TimeSpan");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "TimeSpan");
TimeSpan test = new TimeSpan(15,5,21,45,35) ;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.TimeSpan);
@@ -910,8 +910,8 @@
prop.TimeSpan = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "TimeSpan");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "TimeSpan");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -928,8 +928,8 @@
prop.Account.FirstName = "test";
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Account");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Account");
propertyAccessor.Set(prop, null);
Assert.AreEqual(null, prop.Account);
}
@@ -947,8 +947,8 @@
prop.Account = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Account");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Account");
Assert.AreEqual(HashCodeProvider.GetIdentityHashCode(test), HashCodeProvider.GetIdentityHashCode(prop.Account));
@@ -966,8 +966,8 @@
prop.Account.FirstName = "test";
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Account");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Account");
Account test = new Account();
test.FirstName = "Gilles";
propertyAccessor.Set(prop, test);
@@ -988,8 +988,8 @@
propertyInfo.SetValue(prop, null, null);
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Day");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Day");
propertyAccessor.Set(prop, null);
//Assert.AreEqual(TimeSpan.MinValue, prop.TimeSpan);
}
@@ -1004,8 +1004,8 @@
prop.Day = Days.Thu;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Day");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Day");
Days test = Days.Wed;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.Day);
@@ -1022,8 +1022,8 @@
prop.Day = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "Day");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "Day");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -1039,8 +1039,8 @@
prop.IntNullable = 85;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "IntNullable");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "IntNullable");
propertyAccessor.Set(prop, null);
Assert.AreEqual(null, prop.IntNullable);
}
@@ -1056,8 +1056,8 @@
prop.IntNullable = test;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "IntNullable");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "IntNullable");
Assert.AreEqual(test, propertyAccessor.Get(prop));
}
@@ -1072,8 +1072,8 @@
prop.IntNullable = 99;
// Property accessor
- PropertyAccessorFactory factory = new PropertyAccessorFactory(true);
- IPropertyAccessor propertyAccessor = factory.CreatePropertyAccessor(typeof(Property), "IntNullable");
+ MemberAccessorFactory factory = new MemberAccessorFactory(true);
+ IMemberAccessor propertyAccessor = factory.CreateMemberAccessor(typeof(Property), "IntNullable");
Int32? test = 55;
propertyAccessor.Set(prop, test);
Assert.AreEqual(test, prop.IntNullable);
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj?rev=386438&r1=386437&r2=386438&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.2005.csproj Thu Mar 16 11:42:57 2006
@@ -197,18 +197,20 @@
<Compile Include="Utilities\Objects\EmitObjectFactory.cs" />
<Compile Include="Utilities\Objects\FactoryBuilder.cs" />
<Compile Include="Utilities\Objects\IFactory.cs" />
- <Compile Include="Utilities\Objects\ILPropertyAccessor.cs" />
<Compile Include="Utilities\Objects\IObjectFactory.cs" />
- <Compile Include="Utilities\Objects\IPropertyAccessor.cs" />
+ <Compile Include="Utilities\Objects\Members\EmitFieldAccessor.cs" />
+ <Compile Include="Utilities\Objects\Members\ILPropertyAccessor.cs" />
+ <Compile Include="Utilities\Objects\Members\IMemberAccessor.cs" />
+ <Compile Include="Utilities\Objects\Members\MemberAccessorFactory.cs" />
+ <Compile Include="Utilities\Objects\Members\ReflectionFieldAccessor.cs" />
+ <Compile Include="Utilities\Objects\Members\ReflectionPropertyAccessor.cs" />
<Compile Include="Utilities\Objects\ObjectFactory.cs" />
<Compile Include="Utilities\Objects\ObjectProbe.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Utilities\Objects\PropertyAccessorFactory.cs" />
<Compile Include="Utilities\Objects\ReflectionInfo.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Utilities\Objects\ReflectionPropertyAccessor.cs" />
<Compile Include="Utilities\Proxy\CachedProxyGenerator.cs">
<SubType>Code</SubType>
</Compile>
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=386438&r1=386437&r2=386438&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Thu Mar 16 11:42:57 2006
@@ -325,42 +325,52 @@
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\ILPropertyAccessor.cs"
+ RelPath = "Utilities\Objects\IObjectFactory.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\IObjectFactory.cs"
+ RelPath = "Utilities\Objects\ObjectFactory.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\IPropertyAccessor.cs"
+ RelPath = "Utilities\Objects\ObjectProbe.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\ObjectFactory.cs"
+ RelPath = "Utilities\Objects\ReflectionInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\ObjectProbe.cs"
+ RelPath = "Utilities\Objects\Members\EmitFieldAccessor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\PropertyAccessorFactory.cs"
+ RelPath = "Utilities\Objects\Members\ILPropertyAccessor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\ReflectionInfo.cs"
+ RelPath = "Utilities\Objects\Members\IMemberAccessor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Utilities\Objects\Members\MemberAccessorFactory.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Utilities\Objects\Members\ReflectionFieldAccessor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Utilities\Objects\ReflectionPropertyAccessor.cs"
+ RelPath = "Utilities\Objects\Members\ReflectionPropertyAccessor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,102 @@
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Reflection;
+using System.Reflection.Emit;
+using IBatisNet.Common.Exceptions;
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// The EmitFieldAccessor class provides an IL-based access
+ /// to a field of a specified target class.
+ /// </summary>
+ public class EmitFieldAccessor : IMemberAccessor
+ {
+ private Type _targetType = null;
+ private string _fieldName = string.Empty;
+ private Type _fieldType = null;
+ private IMemberAccessor _emittedFieldAccessor = null;
+ private AssemblyBuilder _assemblyBuilder = null;
+ private ModuleBuilder _moduleBuilder = null;
+ private object _nullInternal = null;
+
+ private static IDictionary _typeToOpcode = new HybridDictionary();
+
+ /// <summary>
+ /// Static constructor
+ /// "Initialize a private hashtable with type-opCode pairs
+ /// </summary>
+ static EmitFieldAccessor()
+ {
+ _typeToOpcode[typeof(sbyte)] = OpCodes.Ldind_I1;
+ _typeToOpcode[typeof(byte)] = OpCodes.Ldind_U1;
+ _typeToOpcode[typeof(char)] = OpCodes.Ldind_U2;
+ _typeToOpcode[typeof(short)] = OpCodes.Ldind_I2;
+ _typeToOpcode[typeof(ushort)] = OpCodes.Ldind_U2;
+ _typeToOpcode[typeof(int)] = OpCodes.Ldind_I4;
+ _typeToOpcode[typeof(uint)] = OpCodes.Ldind_U4;
+ _typeToOpcode[typeof(long)] = OpCodes.Ldind_I8;
+ _typeToOpcode[typeof(ulong)] = OpCodes.Ldind_I8;
+ _typeToOpcode[typeof(bool)] = OpCodes.Ldind_I1;
+ _typeToOpcode[typeof(double)] = OpCodes.Ldind_R8;
+ _typeToOpcode[typeof(float)] = OpCodes.Ldind_R4;
+ }
+
+
+ /// <summary>
+ /// Creates a new IL field accessor.
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="fieldName">Field name.</param>
+ /// <param name="assemblyBuilder"></param>
+ /// <param name="moduleBuilder"></param>
+ public EmitFieldAccessor(Type targetType, string fieldName, AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
+ {
+ this._assemblyBuilder = assemblyBuilder;
+ this._moduleBuilder = moduleBuilder;
+ this._targetType = targetType;
+ this._fieldName = fieldName;
+
+ FieldInfo fieldInfo = targetType.GetField(fieldName);
+
+ // Make sure the property exists
+ if(fieldInfo == null)
+ {
+ throw new ProbeException(
+ string.Format("Field \"{0}\" does not exist for type "
+ + "{1}.", fieldName, targetType));
+ }
+ else
+ {
+ this._fieldType = fieldInfo.FieldType;
+// this.Emit();
+ }
+ }
+
+ #region IMemberAccessor Members
+
+ /// <summary>
+ /// Gets the field value from the specified target.
+ /// </summary>
+ /// <param name="target">Target object.</param>
+ /// <returns>Property value.</returns>
+ public object Get(object target)
+ {
+ // TODO: Add EmitFieldAccessor.Get implementation
+ return null;
+ }
+
+ /// <summary>
+ /// Sets the field for the specified target.
+ /// </summary>
+ /// <param name="target">Target object.</param>
+ /// <param name="value">Value to set.</param>
+ public void Set(object target, object value)
+ {
+ // TODO: Add EmitFieldAccessor.Set implementation
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/EmitFieldAccessor.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,293 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * 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 System.Collections;
+using System.Collections.Specialized;
+using System.Reflection;
+using System.Reflection.Emit;
+using IBatisNet.Common.Exceptions;
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// The EmitPropertyAccessor class provides an IL-based access
+ /// to a property of a specified target class.
+ /// </summary>
+ public class EmitPropertyAccessor : IMemberAccessor
+ {
+ private Type _targetType = null;
+ private string _propertyName = string.Empty;
+ private Type _propertyType = null;
+ private IMemberAccessor _emittedPropertyAccessor = null;
+ private AssemblyBuilder _assemblyBuilder = null;
+ private ModuleBuilder _moduleBuilder = null;
+ private object _nullInternal = null;
+
+ private static IDictionary _typeToOpcode = new HybridDictionary();
+
+ /// <summary>
+ /// Static constructor
+ /// "Initialize a private hashtable with type-opCode pairs
+ /// </summary>
+ static EmitPropertyAccessor()
+ {
+ _typeToOpcode[typeof(sbyte)] = OpCodes.Ldind_I1;
+ _typeToOpcode[typeof(byte)] = OpCodes.Ldind_U1;
+ _typeToOpcode[typeof(char)] = OpCodes.Ldind_U2;
+ _typeToOpcode[typeof(short)] = OpCodes.Ldind_I2;
+ _typeToOpcode[typeof(ushort)] = OpCodes.Ldind_U2;
+ _typeToOpcode[typeof(int)] = OpCodes.Ldind_I4;
+ _typeToOpcode[typeof(uint)] = OpCodes.Ldind_U4;
+ _typeToOpcode[typeof(long)] = OpCodes.Ldind_I8;
+ _typeToOpcode[typeof(ulong)] = OpCodes.Ldind_I8;
+ _typeToOpcode[typeof(bool)] = OpCodes.Ldind_I1;
+ _typeToOpcode[typeof(double)] = OpCodes.Ldind_R8;
+ _typeToOpcode[typeof(float)] = OpCodes.Ldind_R4;
+ }
+
+
+ /// <summary>
+ /// Creates a new IL property accessor.
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="propertyName">Property name.</param>
+ /// <param name="assemblyBuilder"></param>
+ /// <param name="moduleBuilder"></param>
+ public EmitPropertyAccessor(Type targetType, string propertyName, AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
+ {
+ this._assemblyBuilder = assemblyBuilder;
+ this._moduleBuilder = moduleBuilder;
+ this._targetType = targetType;
+ this._propertyName = propertyName;
+
+ PropertyInfo propertyInfo = targetType.GetProperty(propertyName);
+
+ // Make sure the property exists
+ if(propertyInfo == null)
+ {
+ throw new ProbeException(
+ string.Format("Property \"{0}\" does not exist for type "
+ + "{1}.", propertyName, targetType));
+ }
+ else
+ {
+ this._propertyType = propertyInfo.PropertyType;
+ this.Init();
+ }
+ }
+
+
+ /// <summary>
+ /// Gets the property value from the specified target.
+ /// </summary>
+ /// <param name="target">Target object.</param>
+ /// <returns>Property value.</returns>
+ public object Get(object target)
+ {
+ return this._emittedPropertyAccessor.Get(target);
+ }
+
+ /// <summary>
+ /// Sets the property for the specified target.
+ /// </summary>
+ /// <param name="target">Target object.</param>
+ /// <param name="value">Value to set.</param>
+ public void Set(object target, object value)
+ {
+ // If the value to assign is null and assign null internal value
+ object newValue = value;
+ if (newValue == null)
+ {
+ newValue = _nullInternal;
+ }
+
+ this._emittedPropertyAccessor.Set(target, newValue);
+ }
+
+ private object GetNullInternal(Type type)
+ {
+ if (type.IsValueType)
+ {
+ if (type.IsEnum)
+ {
+ return GetNullInternal( Enum.GetUnderlyingType(type) );
+ }
+
+ if (type.IsPrimitive)
+ {
+ if (type == typeof(Int32)) {return 0; }
+ if (type == typeof(Double)) {return (Double)0; }
+ if (type == typeof(Int16)) {return (Int16)0; }
+ if (type == typeof(SByte)) {return (SByte)0; }
+ if (type == typeof(Int64)) {return (Int64)0; }
+ if (type == typeof(Byte)) {return (Byte)0; }
+ if (type == typeof(UInt16)) {return (UInt16)0; }
+ if (type == typeof(UInt32)) {return (UInt32)0; }
+ if (type == typeof(UInt64)) {return (UInt64)0; }
+ if (type == typeof(UInt64)) {return (UInt64)0; }
+ if (type == typeof(Single)) {return (Single)0; }
+ if (type == typeof(Boolean)) {return false; }
+ if (type == typeof(char)) {return '\0'; }
+ }
+ else
+ {
+ if (type == typeof(DateTime)) {return DateTime.MinValue; }
+ if (type == typeof(Decimal)) {return 0m; }
+ if (type == typeof(Guid)) {return Guid.Empty; }
+ if (type == typeof(TimeSpan)) { return TimeSpan.MinValue; }
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// This method generates creates a new assembly containing
+ /// the Type that will provide dynamic access.
+ /// </summary>
+ private void Init()
+ {
+ // Create the assembly and an instance of the property accessor class.
+ EmitType();
+
+ _emittedPropertyAccessor = _assemblyBuilder.CreateInstance("PropertyAccessorFor" + _targetType.FullName + _propertyName) as IMemberAccessor;
+
+ _nullInternal = GetNullInternal(_propertyType);
+
+ if(_emittedPropertyAccessor == null)
+ {
+ throw new ProbeException(string.Format("Unable to create property accessor for \"{0}\".", _propertyName));
+ }
+ }
+
+ /// <summary>
+ /// Create an assembly that will provide the get and set methods.
+ /// </summary>
+ private void EmitType()
+ {
+ // Define a public class named "Property..." in the assembly.
+ TypeBuilder typeBuilder = _moduleBuilder.DefineType("PropertyAccessorFor" + _targetType.FullName + _propertyName, TypeAttributes.Public);
+
+ // Mark the class as implementing IPropertyAccessor.
+ typeBuilder.AddInterfaceImplementation(typeof(IMemberAccessor));
+
+ // Add a constructor
+ typeBuilder.DefineDefaultConstructor(MethodAttributes.Public);
+
+ // Define a method for the get operation.
+ Type[] getParamTypes = new Type[] {typeof(object)};
+ MethodBuilder getMethod =
+ typeBuilder.DefineMethod("Get",
+ MethodAttributes.Public | MethodAttributes.Virtual,
+ typeof(object),
+ getParamTypes);
+
+ // From the method, get an ILGenerator. This is used to
+ // emit the IL that we want.
+ ILGenerator getIL = getMethod.GetILGenerator();
+
+ // Emit the IL.
+ MethodInfo targetGetMethod = this._targetType.GetMethod("get_" + this._propertyName);
+
+ if(targetGetMethod != null)
+ {
+ getIL.DeclareLocal(typeof(object));
+ getIL.Emit(OpCodes.Ldarg_1); //Load the first argument,(target object)
+ getIL.Emit(OpCodes.Castclass, this._targetType); //Cast to the source type
+ getIL.EmitCall(OpCodes.Call, targetGetMethod, null); //Get the property value
+
+ if(targetGetMethod.ReturnType.IsValueType)
+ {
+ getIL.Emit(OpCodes.Box, targetGetMethod.ReturnType); //Box if necessary
+ }
+ getIL.Emit(OpCodes.Stloc_0); //Store it
+
+ getIL.Emit(OpCodes.Ldloc_0);
+ }
+ else
+ {
+ getIL.ThrowException(typeof(MissingMethodException));
+ }
+
+ getIL.Emit(OpCodes.Ret);
+
+
+ // Define a method for the set operation.
+ Type[] setParamTypes = new Type[] {typeof(object), typeof(object)};
+ MethodBuilder setMethod =
+ typeBuilder.DefineMethod("Set",
+ MethodAttributes.Public | MethodAttributes.Virtual,
+ null,
+ setParamTypes);
+
+ // From the method, get an ILGenerator. This is used to
+ // emit the IL that we want.
+ ILGenerator setIL = setMethod.GetILGenerator();
+ // Emit the IL.
+ MethodInfo targetSetMethod = this._targetType.GetMethod("set_" + this._propertyName);
+ if(targetSetMethod != null)
+ {
+ Type paramType = targetSetMethod.GetParameters()[0].ParameterType;
+
+ setIL.DeclareLocal(paramType);
+ setIL.Emit(OpCodes.Ldarg_1); //Load the first argument
+ //(target object)
+ setIL.Emit(OpCodes.Castclass, this._targetType); //Cast to the source type
+
+ setIL.Emit(OpCodes.Ldarg_2); //Load the second argument
+ //(value object)
+ if(paramType.IsValueType)
+ {
+ setIL.Emit(OpCodes.Unbox, paramType); //Unbox it
+ if(_typeToOpcode[paramType]!=null) //and load
+ {
+ OpCode load = (OpCode)_typeToOpcode[paramType];
+ setIL.Emit(load);
+ }
+ else
+ {
+ setIL.Emit(OpCodes.Ldobj,paramType);
+ }
+ }
+ else
+ {
+ setIL.Emit(OpCodes.Castclass, paramType); //Cast class
+ }
+
+ setIL.EmitCall(OpCodes.Callvirt,
+ targetSetMethod, null); //Set the property value
+ }
+ else
+ {
+ setIL.ThrowException(typeof(MissingMethodException));
+ }
+ setIL.Emit(OpCodes.Ret);
+
+ // Load the type
+ typeBuilder.CreateType();
+ }
+ }
+}
\ No newline at end of file
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ILPropertyAccessor.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,50 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * 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
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// The IMemberAccessor interface defines a field/property
+ /// accessor.
+ /// </summary>
+ public interface IMemberAccessor
+ {
+ /// <summary>
+ /// Gets the value stored in the property for
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to retrieve the field/property from.</param>
+ /// <returns>Property value.</returns>
+ object Get(object target);
+
+ /// <summary>
+ /// Sets the value for the property of
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to set the field/property on.</param>
+ /// <param name="value">Property value.</param>
+ void Set(object target, object value);
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/IMemberAccessor.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,190 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * 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 System.Collections;
+using System.Collections.Specialized;
+using System.Reflection;
+using System.Reflection.Emit;
+using IBatisNet.Common.Exceptions;
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// A factory to build IMemberAccessor for a type.
+ /// </summary>
+ public class MemberAccessorFactory
+ {
+ private delegate IMemberAccessor CreateMemberPropertyAccessor(Type targetType, string propertyName);
+ private delegate IMemberAccessor CreateMemberFieldAccessor(Type targetType, string fieldName);
+
+ private CreateMemberPropertyAccessor _createPropertyAccessor = null;
+ private CreateMemberFieldAccessor _createFieldAccessor = null;
+
+ private IDictionary _cachedIMemberAccessor = new HybridDictionary();
+ private AssemblyBuilder _assemblyBuilder = null;
+ private ModuleBuilder _moduleBuilder = null;
+ private object _padlock = new object();
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="allowCodeGeneration"></param>
+ public MemberAccessorFactory(bool allowCodeGeneration)
+ {
+ if (allowCodeGeneration)
+ {
+ AssemblyName assemblyName = new AssemblyName();
+ assemblyName.Name = "iBATIS.FastPropertyAccessor"+HashCodeProvider.GetIdentityHashCode(this).ToString();
+
+ // Create a new assembly with one module
+ _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
+ _moduleBuilder = _assemblyBuilder.DefineDynamicModule(assemblyName.Name + ".dll");
+
+ // Detect runtime environment and create the appropriate factory
+ if (Environment.Version.Major >= 2)
+ {
+ // To Do : a custom factory for .NET V2
+ // optimize with DynamicMethod or Delegate.CreateDelegate
+ _createPropertyAccessor = new CreateMemberPropertyAccessor(CreateEmitPropertyAccessor);
+ _createFieldAccessor = new CreateMemberFieldAccessor(CreateEmitFieldAccessor);
+
+ }
+ else
+ {
+ _createPropertyAccessor = new CreateMemberPropertyAccessor(CreateEmitPropertyAccessor);
+ _createFieldAccessor = new CreateMemberFieldAccessor(CreateEmitFieldAccessor);
+ }
+ }
+ else
+ {
+ _createPropertyAccessor = new CreateMemberPropertyAccessor(CreateReflectionPropertyAccessor);
+ _createFieldAccessor = new CreateMemberFieldAccessor(CreateReflectionFieldAccessor);
+ }
+
+ }
+
+ /// <summary>
+ /// Generate an IPropertyAccessor object
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="name">Field or Property name.</param>
+ /// <returns>null if the generation fail</returns>
+ public IMemberAccessor CreateMemberAccessor(Type targetType, string name)
+ {
+ string key = targetType.FullName+name;
+
+ if (_cachedIMemberAccessor.Contains(key))
+ {
+ return (IMemberAccessor)_cachedIMemberAccessor[key];
+ }
+ else
+ {
+ IMemberAccessor memberAccessor = null;
+ lock (_padlock)
+ {
+ if (!_cachedIMemberAccessor.Contains(key))
+ {
+ // Property
+ PropertyInfo propertyInfo = targetType.GetProperty(name);
+
+ if (propertyInfo!=null)
+ {
+ memberAccessor = _createPropertyAccessor(targetType, name);
+ _cachedIMemberAccessor[key] = memberAccessor;
+ }
+ else
+ {
+ // Field
+ FieldInfo fieldInfo = targetType.GetField(name);
+
+ if (fieldInfo!=null)
+ {
+ memberAccessor = _createFieldAccessor(targetType, name);
+ _cachedIMemberAccessor[key] = memberAccessor;
+ }
+ else
+ {
+ throw new ProbeException(
+ string.Format("No property or field named \"{0}\" exist for type "
+ + "{1}.",name, targetType));
+ }
+ }
+ }
+ else
+ {
+ memberAccessor = (IMemberAccessor)_cachedIMemberAccessor[key];
+ }
+ }
+ return memberAccessor;
+ }
+ }
+
+
+ /// <summary>
+ /// Generate a ILPropertyAccessor object
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="propertyName">Property name.</param>
+ /// <returns>null if the generation fail</returns>
+ private IMemberAccessor CreateEmitPropertyAccessor(Type targetType, string propertyName)
+ {
+ return new EmitPropertyAccessor(targetType, propertyName, _assemblyBuilder, _moduleBuilder);
+ }
+
+ /// <summary>
+ /// Generate a EmitPropertyAccessor object
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="fieldName">Field name.</param>
+ /// <returns>null if the generation fail</returns>
+ private IMemberAccessor CreateEmitFieldAccessor(Type targetType, string fieldName)
+ {
+ return new EmitFieldAccessor(targetType, fieldName, _assemblyBuilder, _moduleBuilder);
+ }
+
+ /// <summary>
+ /// Generate a ReflectionPropertyAccessor object
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="propertyName">Property name.</param>
+ /// <returns>null if the generation fail</returns>
+ private IMemberAccessor CreateReflectionPropertyAccessor(Type targetType, string propertyName)
+ {
+ return new ReflectionPropertyAccessor(targetType, propertyName);
+ }
+
+ /// <summary>
+ /// Generate a ReflectionFieldAccessor object
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="fieldName">field name.</param>
+ /// <returns>null if the generation fail</returns>
+ private IMemberAccessor CreateReflectionFieldAccessor(Type targetType, string fieldName)
+ {
+ return new ReflectionFieldAccessor(targetType, fieldName);
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/MemberAccessorFactory.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,75 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * 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;
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// The ReflectionFieldAccessor class provides an reflection access
+ /// to a field of a specified target class.
+ /// </summary>
+ public class ReflectionFieldAccessor : IMemberAccessor
+ {
+ /// <summary>
+ /// Creates a new Reflection field accessor.
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="fieldName">Field name.</param>
+ public ReflectionFieldAccessor(Type targetType, string fieldName)
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ #region IMemberAccessor Members
+
+ /// <summary>
+ /// Gets the value stored in the field for
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to retrieve the property from.</param>
+ /// <returns>Property value.</returns>
+ public object Get(object target)
+ {
+ // TODO: Add ReflectionFieldAccessor.Get implementation
+ return null;
+ }
+
+ /// <summary>
+ /// Sets the value for the field of
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to set the property on.</param>
+ /// <param name="value">Property value.</param>
+ public void Set(object target, object value)
+ {
+ // TODO: Add ReflectionFieldAccessor.Set implementation
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionFieldAccessor.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs?rev=386438&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs Thu Mar 16 11:42:57 2006
@@ -0,0 +1,69 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * 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;
+
+namespace IBatisNet.Common.Utilities.Objects.Members
+{
+ /// <summary>
+ /// The ReflectionPropertyAccessor class provides an reflection access
+ /// to a property of a specified target class.
+ /// </summary>
+ public class ReflectionPropertyAccessor : IMemberAccessor
+ {
+
+ /// <summary>
+ /// Creates a new Reflection property accessor.
+ /// </summary>
+ /// <param name="targetType">Target object type.</param>
+ /// <param name="propertyName">Property name.</param>
+ public ReflectionPropertyAccessor(Type targetType, string propertyName)
+ {
+ }
+
+ #region IMemberAccessor Members
+ /// <summary>
+ /// Gets the value stored in the property for
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to retrieve the property from.</param>
+ /// <returns>Property value.</returns>
+ public object Get(object target)
+ {
+ return null;
+ }
+
+ /// <summary>
+ /// Sets the value for the property of
+ /// the specified target.
+ /// </summary>
+ /// <param name="target">Object to set the property on.</param>
+ /// <param name="value">Property value.</param>
+ public void Set(object target, object value)
+ {
+ }
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/ReflectionPropertyAccessor.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy