You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2006/05/18 22:25:04 UTC
svn commit: r407629 [1/2] - in /ibatis/trunk/cs/mapper:
IBatisNet.DataMapper.Test/ IBatisNet.DataMapper.Test/Domain/
IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/
IBatisNet.DataMapper.Test/NUnit/SqlMapTests/
IBatisNet.DataMapper.Test/NUnit/SqlMapTest...
Author: gbayon
Date: Thu May 18 13:25:03 2006
New Revision: 407629
URL: http://svn.apache.org/viewvc?rev=407629&view=rev
Log:
- Added support for proxy and generic list
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/GenericListTests.txt
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListGeneric.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListGenericFactory.cs (with props)
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/LineItemCollection2.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Order.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheController/CacheModelTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/StatementTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ResultMapTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/SelectStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadProxyFactory.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/LineItemCollection2.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/LineItemCollection2.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/LineItemCollection2.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/LineItemCollection2.cs Thu May 18 13:25:03 2006
@@ -9,5 +9,14 @@
[Serializable]
public class LineItemCollection2 : Collection<LineItem>
{
+ public virtual new int Count
+ {
+ get { return base.Count; }
+ }
+
+ public virtual new int IndexOf(LineItem item)
+ {
+ return base.IndexOf(item);
+ }
}
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Order.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Order.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Order.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Order.cs Thu May 18 13:25:03 2006
@@ -23,7 +23,7 @@
private string _province;
private string _postalCode;
private IList _lineItemsIList;
- private LineItemCollection _lineItems;//LineItemCollection
+ private LineItemCollection _collection;
private LineItem[] _lineItemsArray;
private LineItem _favouriteLineItem;
@@ -54,7 +54,7 @@
{
_id = id;
_account = account;
- _lineItems = collection;
+ _collection = collection;
}
@@ -67,7 +67,7 @@
}
private LineItemCollection2 _genericCollection = null;
- public LineItemCollection2 LineItemsCollection
+ public LineItemCollection2 LineItemsCollection2
{
get { return _genericCollection; }
set { _genericCollection = value; }
@@ -90,12 +90,11 @@
set { _genericList = value; }
}
- private LineItemCollection _collection = null;
- public LineItemCollection LineItemsCollection
- {
- get { return _collection; }
- set { _collection = value; }
- }
+ public LineItemCollection LineItemsCollection2
+ {
+ get { return _collection; }
+ set { _collection = value; }
+ }
public Order(IList lineItems)
{
@@ -121,10 +120,10 @@
}
- public LineItemCollection LineItems
+ public LineItemCollection LineItemsCollection
{
- get { return _lineItems; }
- set { _lineItems = value; }
+ get { return _collection; }
+ set { _collection = value; }
}
public LineItem[] LineItemsArray
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj?rev=407629&r1=407628&r2=407629&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 May 18 13:25:03 2006
@@ -389,6 +389,7 @@
<Content Include="Maps\PostgreSQL\Npgsql\Other.xml" />
<Content Include="Maps\PostgreSQL\Npgsql\ParameterClass.xml" />
<Content Include="Maps\PostgreSQL\Npgsql\ResultClass.xml" />
+ <Content Include="NUnit\SqlMapTests\Generics\GenericListTests.txt" />
<Content Include="ReadMe.txt" />
<Content Include="Scripts\Access\account-init.sql" />
<Content Include="Scripts\Access\account-procedure.sql" />
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/LineItem.xml Thu May 18 13:25:03 2006
@@ -7,6 +7,7 @@
<alias>
<typeAlias alias="LineItem" type="IBatisNet.DataMapper.Test.Domain.LineItem, IBatisNet.DataMapper.Test" />
<typeAlias alias="LineItemCollection" type="IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test" />
+ <typeAlias alias="LineItemCollection2" type="${collection2Namespace}" />
</alias>
<resultMaps>
@@ -69,7 +70,20 @@
from LineItems where Order_ID = #value#
order by LineItem_Code
</statement>
-
+
+ <statement id="GetLineItemsForOrderWithListClass2"
+ parameterClass="int"
+ listClass="LineItemCollection2"
+ resultClass="LineItem">
+ select
+ LineItem_ID as Id,
+ LineItem_Code as Code,
+ LineItem_Quantity as Quantity,
+ LineItem_Price as Price
+ from LineItems where Order_ID = #value#
+ order by LineItem_Code
+ </statement>
+
<statement id="GetSpecificLineItem"
parameterClass="Hashtable"
resultClass="LineItem">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml Thu May 18 13:25:03 2006
@@ -94,7 +94,7 @@
<resultMap id="order-result-constructor6" class="Order" >
<constructor>
- <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ <argument argumentName="lineItems" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
</constructor>
<result property="Id" column="Order_ID"/>
<result property="Date" column="Order_Date"/>
@@ -109,7 +109,7 @@
<resultMap id="order-result-constructor7" class="Order" >
<constructor>
- <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+ <argument argumentName="collection" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
</constructor>
<result property="Id" column="Order_ID"/>
<result property="Date" column="Order_Date"/>
@@ -137,22 +137,32 @@
<result property="Province" column="Order_Province"/>
<result property="PostalCode" column="Order_PostalCode"/>
</resultMap>
-
- <resultMap id="order-with-generic-lazy-load" class="Order"
- extends="lite-order-result-by-name" >
- <result property="LineItemsGenericList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
- </resultMap>
<resultMap id="order-with-generic-list-lineitem" class="Order"
extends="lite-order-result-by-name" >
<result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrder" />
</resultMap>
+ <resultMap id="order-with-generic-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
+ </resultMap>
+
<resultMap id="order-with-generic-collection-lineitem" class="Order"
extends="lite-order-result-by-name" >
- <result property="LineItemsCollection" column="Order_ID" select="GetLineItemsForOrder" />
+ <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
</resultMap>
+ <resultMap id="order-with-generic-typed-collection-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection2" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
+ <resultMap id="order-with-generic-typed-collection-lineitem-lazy" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection2" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
<resultMap id="order-with-generic-collection-via-sp" class="Order"
extends="lite-order-result-by-name" >
<result property="LineItemsCollection" column="Order_ID" select="SelectLineItemForOrder" />
@@ -163,6 +173,21 @@
<result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
</resultMap>
+ <resultMap id="order-with-generic-lines-result" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
+ <resultMap id="order-with-generic-lines-result-lazy" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
+ <resultMap id="order-with-generic-collection" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection2" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
<resultMap id="order-with-lines-result-statement-namespaces" class="Order"
extends="lite-order-result-by-name" >
<result property="LineItemsIList" lazyLoad="true" column="Order_ID" select="LineItem.GetLineItemsForOrder" />
@@ -170,7 +195,7 @@
<resultMap id="order-with-lines-collection" class="Order"
extends="lite-order-result-by-name" >
- <result property="LineItems" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass" />
+ <result property="LineItemsCollection" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass" />
</resultMap>
<resultMap id="order-with-lines-array" class="Order"
@@ -256,7 +281,7 @@
<result property="Province" column="Order_Province"/>
<result property="PostalCode" column="Order_PostalCode"/>
<result property="LineItemsIList" column="Order_ID" select="GetLineItemsForOrder" />
- <result property="LineItems" column="Order_ID" select="GetLineItemsForOrder" lazyLoad="false" />
+ <result property="LineItemsCollection" column="Order_ID" select="GetLineItemsForOrder" lazyLoad="false" />
</resultMap>
<resultMap id="order-with-favourite-line-item" class="Order">
@@ -343,6 +368,18 @@
WHERE Orders.Order_ID = #value#
</select>-->
+ <statement id="GetOrderWithGenericLineItems"
+ parameterClass="Integer"
+ resultMap="order-with-generic-lines-result" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithGenericLineItemsLazy"
+ parameterClass="Integer"
+ resultMap="order-with-generic-lines-result-lazy" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderWithGenericLazyLoad"
parameterClass="Integer"
resultMap="order-with-generic-lazy-load" >
@@ -362,6 +399,18 @@
select * from Orders where Order_ID = #value#
</statement>
+ <statement id="GetOrderWithGenericTypedLineItemCollection"
+ parameterClass="Integer"
+ resultMap="order-with-generic-typed-collection-lineitem" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+ <statement id="GetOrderWithGenericTypedLineItemCollectionLazy"
+ parameterClass="Integer"
+ resultMap="order-with-generic-typed-collection-lineitem-lazy" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
<statement id="GetOrderWithGenericViaSP"
parameterClass="Integer"
resultMap="order-with-generic-collection-via-sp" >
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs Thu May 18 13:25:03 2006
@@ -14,6 +14,7 @@
using IBatisNet.Common.Utilities; // ScriptRunner definition
using IBatisNet.DataMapper; // SqlMap API
using IBatisNet.DataMapper.Test.Domain;
+using System.Collections.Specialized;
[assembly : log4net.Config.XmlConfigurator(Watch=true)]
@@ -62,10 +63,17 @@
DomSqlMapBuilder builder = new DomSqlMapBuilder();
#if dotnet2
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace","IBatisNet.DataMapper.Test.Domain.LineItemCollection2, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
string fileName = "sqlmap" + "_" + ConfigurationManager.AppSettings["database"] + "_" + ConfigurationManager.AppSettings["providerType"] + ".config";
#else
- string fileName = "sqlmap" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config";
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace","IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+ string fileName = "sqlmap" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config";
#endif
try
{
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheController/CacheModelTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheController/CacheModelTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheController/CacheModelTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheController/CacheModelTest.cs Thu May 18 13:25:03 2006
@@ -40,13 +40,13 @@
Order order = new Order();
order.CardNumber = "CardNumber";
order.Date = DateTime.Now;
- order.LineItems = new LineItemCollection();
+ order.LineItemsCollection = new LineItemCollection();
LineItem item = new LineItem();
item.Code = "Code1";
- order.LineItems.Add( item );
+ order.LineItemsCollection.Add(item);
item = new LineItem();
item.Code = "Code2";
- order.LineItems.Add( item );
+ order.LineItemsCollection.Add(item);
CacheKey key = new CacheKey();
key.Update(order);
@@ -83,13 +83,13 @@
Order order = new Order();
order.CardNumber = "CardNumber";
order.Date = DateTime.Now;
- order.LineItems = new LineItemCollection();
+ order.LineItemsCollection = new LineItemCollection();
LineItem item = new LineItem();
item.Code = "Code1";
- order.LineItems.Add( item );
+ order.LineItemsCollection.Add(item);
item = new LineItem();
item.Code = "Code2";
- order.LineItems.Add( item );
+ order.LineItemsCollection.Add(item);
CacheKey key = new CacheKey();
key.Update(order);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs Thu May 18 13:25:03 2006
@@ -6,6 +6,7 @@
using IBatisNet.DataMapper; // SqlMap API
using IBatisNet.DataMapper.Configuration;
using NUnit.Framework;
+using System.Collections.Specialized;
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
{
@@ -43,8 +44,12 @@
public void TestConfigureRelativePath()
{
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( _fileName );
- //SqlMapper.Configure( _fileName );
Assert.IsNotNull(sqlMap);
}
@@ -56,10 +61,15 @@
public void TestConfigureAndWatchRelativePath()
{
ConfigureHandler handler = new ConfigureHandler(Configure);
+
+
DomSqlMapBuilder builder = new DomSqlMapBuilder();
- SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
- //SqlMapper sqlMap = SqlMapper.ConfigureAndWatch( _fileName , handler);
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
+ SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
}
@@ -71,10 +81,14 @@
public void TestConfigureRelativePathViaBuilder()
{
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( _fileName );
Assert.IsNotNull(sqlMap);
-
}
/// <summary>
@@ -86,6 +100,11 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
@@ -103,9 +122,12 @@
_fileName = Resources.BaseDirectory+Path.DirectorySeparatorChar+_fileName;
DomSqlMapBuilder builder = new DomSqlMapBuilder();
- SqlMapper sqlMap = builder.Configure( _fileName );
- //SqlMapper sqlMap = SqlMapper.Configure( _fileName );
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
+ SqlMapper sqlMap = builder.Configure( _fileName );
Assert.IsNotNull(sqlMap);
}
@@ -119,6 +141,11 @@
_fileName = Resources.BaseDirectory+Path.DirectorySeparatorChar+_fileName;
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( _fileName );
Assert.IsNotNull(sqlMap);
@@ -133,6 +160,11 @@
_fileName = "file://"+Resources.BaseDirectory+Path.DirectorySeparatorChar+_fileName;
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( _fileName );
//SqlMapper sqlMap = SqlMapper.Configure( _fileName );
@@ -149,6 +181,11 @@
_fileName = "file://"+Resources.BaseDirectory+Path.DirectorySeparatorChar+_fileName;
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( _fileName );
Assert.IsNotNull(sqlMap);
@@ -164,6 +201,11 @@
FileInfo fileInfo = new FileInfo(_fileName);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( fileInfo );
Assert.IsNotNull(sqlMap);
@@ -179,6 +221,11 @@
Uri uri = new Uri(_fileName);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( uri );
Assert.IsNotNull(sqlMap);
@@ -194,9 +241,12 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
- SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
- //SqlMapper sqlMap = SqlMapper.ConfigureAndWatch( _fileName , handler);
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
+ SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
}
@@ -211,6 +261,11 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
@@ -226,9 +281,12 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
- SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
- //SqlMapper sqlMap = SqlMapper.ConfigureAndWatch( _fileName , handler);
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
+ SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
}
@@ -243,6 +301,11 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.ConfigureAndWatch( _fileName , handler);
Assert.IsNotNull(sqlMap);
@@ -260,6 +323,11 @@
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.ConfigureAndWatch( fileInfo , handler);
Assert.IsNotNull(sqlMap);
@@ -284,6 +352,11 @@
Stream stream = assembly.GetManifestResourceStream("IBatisNet.DataMapper.Test.bin.Debug.SqlMap_MSSQL_SqlClient.config");
DomSqlMapBuilder builder = new DomSqlMapBuilder();
+
+ NameValueCollection properties = new NameValueCollection();
+ properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test");
+ builder.Properties = properties;
+
SqlMapper sqlMap = builder.Configure( stream );
Assert.IsNotNull(sqlMap);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs Thu May 18 13:25:03 2006
@@ -161,8 +161,8 @@
AssertOrder1(order);
AssertAccount1(order.Account);
- Assert.IsNotNull( order.LineItems );
- Assert.AreEqual(2, order.LineItems.Count);
+ Assert.IsNotNull( order.LineItemsCollection );
+ Assert.AreEqual(2, order.LineItemsCollection.Count);
}
#if dotnet2
@@ -188,8 +188,8 @@
Order order = (Order)sqlMap.QueryForObject("GetOrderConstructor7", 1);
AssertOrder1(order);
- Assert.IsNotNull(order.LineItemsCollection);
- Assert.AreEqual(2, order.LineItemsCollection.Count);
+ Assert.IsNotNull(order.LineItemsCollection2);
+ Assert.AreEqual(2, order.LineItemsCollection2.Count);
}
#endif
#endregion
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/GenericListTests.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/GenericListTests.txt?rev=407629&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/GenericListTests.txt (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/GenericListTests.txt Thu May 18 13:25:03 2006
@@ -0,0 +1,88 @@
+Tests
+
+Interface tests
+1) IList<LineItem> (Order.LineItemsGenericList) <--- QueryForList<LineItem>
+2) IList<LineItem> (Order.LineItemsGenericList) <--- QueryForList<LineItem> Lazy load
+3) IList<LineItem> (Order.LineItemsGenericList) <--- QueryForList<LineItem> with listClass = LineItemCollection2
+4) IList<LineItem> (Order.LineItemsGenericList) <--- QueryForList<LineItem> with listClass = LineItemCollection2 lazy
+
+Strongly typed collection tests
+5) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList<LineItem> with listClass = LineItemCollection2
+6) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList<LineItem> with listClass = LineItemCollection2 Lazy load
+
+1/
+
+<resultMap id="order-with-generic-list-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrder" />
+</resultMap>
+
+<statement id="GetOrderWithGenericListLineItem"
+ parameterClass="Integer"
+ resultMap="order-with-generic-list-lineitem" >
+ select * from Orders where Order_ID = #value#
+</statement>
+
+2/
+
+<resultMap id="order-with-generic-lazy-load" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
+</resultMap>
+
+
+<statement id="GetOrderWithGenericLazyLoad"
+ parameterClass="Integer"
+ resultMap="order-with-generic-lazy-load" >
+ select * from Orders where Order_ID = #value#
+</statement>
+
+3/
+
+<resultMap id="order-with-generic-collection-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" select="GetLineItemsForOrderWithListClass" />
+</resultMap>
+
+<statement id="GetOrderWithGenericLineItemCollection"
+ parameterClass="Integer"
+ resultMap="order-with-generic-collection-lineitem" >
+ select * from Orders where Order_ID = #value#
+</statement>
+
+4/
+ <resultMap id="order-with-generic-lines-result-lazy" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsGenericList" column="Order_ID" lazyLoad="true" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
+ <statement id="GetOrderWithGenericLineItemsLazy"
+ parameterClass="Integer"
+ resultMap="order-with-generic-lines-result-lazy" >
+ select * from Orders where Order_ID = #value#
+ </statement>
+
+5/
+<resultMap id="order-with-generic-typed-collection-lineitem" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection2" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+</resultMap>
+
+ <statement id="GetOrderWithGenericTypedLineItemCollection"
+ parameterClass="Integer"
+ resultMap="order-with-generic-typed-collection-lineitem" >
+ select * from Orders where Order_ID = #value#
+</statement>
+
+
+6/
+ <resultMap id="order-with-generic-typed-collection-lineitem-lazy" class="Order"
+ extends="lite-order-result-by-name" >
+ <result property="LineItemsCollection2" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrderWithListClass2" />
+ </resultMap>
+
+ <statement id="GetOrderWithGenericTypedLineItemCollectionLazy"
+ parameterClass="Integer"
+ resultMap="order-with-generic-typed-collection-lineitem-lazy" >
+ select * from Orders where Order_ID = #value#
+ </statement>
\ No newline at end of file
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs Thu May 18 13:25:03 2006
@@ -9,6 +9,19 @@
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests.Generics
{
+ /// <summary>
+ /// Tests generic list
+ ///
+ /// Interface tests
+ /// 1) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt
+ /// 2) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt Lazy load
+ /// 3) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2
+ /// 4) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2 lazy
+
+ /// Strongly typed collection tests
+ /// 5) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2
+ /// 6) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2 Lazy load
+ /// </summary>
[TestFixture]
public class ResultMapTest : BaseTest
{
@@ -38,10 +51,11 @@
#region Result Map test
/// <summary>
- /// Test generic Ilist
+ /// Test generic Ilist :
+ /// 1) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt
/// </summary>
[Test]
- public void TestGenricListMapping()
+ public void TestGenericList()
{
Order order = sqlMap.QueryForObject<Order>("GetOrderWithGenericListLineItem", 1);
@@ -53,10 +67,11 @@
}
/// <summary>
- /// Test generic Ilist with lazy loadind
+ /// Test generic Ilist with lazy loading :
+ /// 2) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt Lazy load
/// </summary>
[Test]
- public void TestGenricListLazyLoad()
+ public void TestGenericListLazyLoad()
{
Order order = sqlMap.QueryForObject<Order>("GetOrderWithGenericLazyLoad", 1);
@@ -68,18 +83,80 @@
}
/// <summary>
- /// Test generic Collection
+ /// Test generic typed generic Collection on generic IList
+ /// 3) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2
/// </summary>
[Test]
- public void TestGenricCollectionMapping()
+ public void TestGenericCollectionOnIList()
{
Order order = sqlMap.QueryForObject<Order>("GetOrderWithGenericLineItemCollection", 1);
AssertOrder1(order);
// Check generic collection
- Assert.IsNotNull(order.LineItemsCollection);
- Assert.AreEqual(2, order.LineItemsCollection.Count);
+ Assert.IsNotNull(order.LineItemsGenericList);
+ Assert.AreEqual(2, order.LineItemsGenericList.Count);
+ LineItemCollection2 lines = (LineItemCollection2)order.LineItemsGenericList;
+ }
+
+ /// <summary>
+ /// Test generic IList with lazy typed collection
+ /// 4) IList&lgt;LineItem&glt (Order.LineItemsGenericList) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2 lazy
+ /// </summary>
+ [Test]
+ public void TestLazyListGenericMapping()
+ {
+ Order order = (Order)sqlMap.QueryForObject("GetOrderWithGenericLineItemsLazy", 1);
+
+ AssertOrder1(order);
+
+ Assert.IsNotNull(order.LineItemsGenericList);
+ Assert.AreEqual(2, order.LineItemsGenericList.Count);
+ LineItemCollection2 lines = (LineItemCollection2)order.LineItemsGenericList;
+ }
+
+ /// <summary>
+ /// Test generic typed generic Collection on generic typed generic Collection
+ /// 5) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2
+ /// </summary>
+ [Test]
+ public void TestTypedCollectionOnTypedCollection()
+ {
+ Order order = (Order)sqlMap.QueryForObject("GetOrderWithGenericTypedLineItemCollection", 1);
+
+ AssertOrder1(order);
+
+ Assert.IsNotNull(order.LineItemsCollection2);
+ Assert.AreEqual(2, order.LineItemsCollection2.Count);
+
+ IEnumerator<LineItem> e = ((IEnumerable<LineItem>)order.LineItemsCollection2).GetEnumerator();
+ while (e.MoveNext())
+ {
+ LineItem item = e.Current;
+ Assert.IsNotNull(item);
+ }
+ }
+
+ /// <summary>
+ /// Test generic typed generic Collection lazy
+ /// 6) LineItemCollection2 (Order.LineItemCollection2) <--- QueryForList&lgt;LineItem&glt with listClass = LineItemCollection2 Lazy load
+ /// </summary>
+ [Test]
+ public void TestTypedCollectionLazy()
+ {
+ Order order = (Order)sqlMap.QueryForObject("GetOrderWithGenericTypedLineItemCollectionLazy", 1);
+
+ AssertOrder1(order);
+
+ Assert.IsNotNull(order.LineItemsCollection2);
+ Assert.AreEqual(2, order.LineItemsCollection2.Count);
+
+ IEnumerator<LineItem> e = ((IEnumerable<LineItem>)order.LineItemsCollection2).GetEnumerator();
+ while (e.MoveNext())
+ {
+ LineItem item = e.Current;
+ Assert.IsNotNull(item);
+ }
}
#endregion
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/StatementTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/StatementTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/StatementTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/StatementTest.cs Thu May 18 13:25:03 2006
@@ -298,6 +298,25 @@
/// Test QueryForList with Hashtable ResultMap
/// </summary>
[Test]
+ public void TestQueryForListWithGeneric()
+ {
+ List<Account> accounts = new List<Account>();
+
+ sqlMap.QueryForList("GetAllAccountsViaResultMap", null, (System.Collections.IList)accounts);
+
+ AssertAccount1(accounts[0]);
+ Assert.AreEqual(5, accounts.Count);
+ Assert.AreEqual(1, accounts[0].Id);
+ Assert.AreEqual(2, accounts[1].Id);
+ Assert.AreEqual(3, accounts[2].Id);
+ Assert.AreEqual(4, accounts[3].Id);
+ Assert.AreEqual(5, accounts[4].Id);
+ }
+
+ /// <summary>
+ /// Test QueryForList with Hashtable ResultMap
+ /// </summary>
+ [Test]
public void TestQueryForListWithHashtableResultMap()
{
IList<Hashtable> list = sqlMap.QueryForList<Hashtable>("GetAllAccountsAsHashMapViaResultMap", null);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ResultMapTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ResultMapTest.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ResultMapTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ResultMapTest.cs Thu May 18 13:25:03 2006
@@ -127,16 +127,17 @@
AssertOrder1(order);
- Assert.IsNotNull(order.LineItems);
- Assert.AreEqual(2, order.LineItems.Count);
+ Assert.IsNotNull(order.LineItemsCollection);
+ Assert.AreEqual(2, order.LineItemsCollection.Count);
- IEnumerator e = ((IEnumerable)order.LineItems).GetEnumerator();
+ IEnumerator e = ((IEnumerable)order.LineItemsCollection).GetEnumerator();
while(e.MoveNext())
{
LineItem item = (LineItem)e.Current;
Assert.IsNotNull(item);
}
}
+
/// <summary>
/// Test null value replacement(on string) in a Result property.
/// </summary>
@@ -205,8 +206,8 @@
AssertOrder1(order);
// Check strongly typed collection
- Assert.IsNotNull(order.LineItems);
- Assert.AreEqual(2, order.LineItems.Count);
+ Assert.IsNotNull(order.LineItemsCollection);
+ Assert.AreEqual(2, order.LineItemsCollection.Count);
}
/// <summary>
@@ -223,7 +224,6 @@
// Check IList collection
Assert.IsNotNull(order.LineItemsIList);
Assert.AreEqual(2, order.LineItemsIList.Count);
-
}
/// <summary>
@@ -250,10 +250,10 @@
AssertOrder1(order);
- Assert.IsNotNull(order.LineItems);
- Assert.AreEqual(2, order.LineItems.Count);
+ Assert.IsNotNull(order.LineItemsCollection);
+ Assert.AreEqual(2, order.LineItemsCollection.Count);
- IEnumerator e = ((IEnumerable)order.LineItems).GetEnumerator();
+ IEnumerator e = ((IEnumerable)order.LineItemsCollection).GetEnumerator();
while(e.MoveNext())
{
LineItem item = (LineItem)e.Current;
@@ -500,7 +500,31 @@
Assert.AreEqual(System.DateTime.MinValue, orderTest.Date);
}
+//#if dotnet2
+
+
+// /// <summary>
+// /// Test lazy mapping
+// /// </summary>
+// [Test]
+// public void TestLazyWithGenericStronglyTypedCollection()
+// {
+// Order order = (Order)sqlMap.QueryForObject("GetOrderWithLineItemCollection2", 1);
+
+// AssertOrder1(order);
+
+// Assert.IsNotNull(order.LineItemsCollection2);
+// Assert.AreEqual(2, order.LineItemsCollection2.Count);
+
+// IEnumerator<LineItem> e = ((IEnumerable<LineItem>)order.LineItemsCollection2).GetEnumerator();
+// while (e.MoveNext())
+// {
+// LineItem item = e.Current;
+// Assert.IsNotNull(item);
+// }
+// }
+//#endif
#endregion
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config Thu May 18 13:25:03 2006
@@ -36,13 +36,13 @@
<arg key="level" value="ALL" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" />
</logFactoryAdapter> -->
-<!--
+ <!--
<logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
<arg key="configType" value="inline" />
</logFactoryAdapter>
--->
+-->
+
<logFactoryAdapter type="IBatisNet.Common.Logging.Impl.NoOpLoggerFA, IBatisNet.Common" />
-
</logging>
</iBATIS>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Thu May 18 13:25:03 2006
@@ -294,12 +294,23 @@
private ISetAccessorFactory _setAccessorFactory = null;
private IGetAccessorFactory _getAccessorFactory = null;
private bool _validateSqlMapConfig = true;
+ private NameValueCollection _properties = new NameValueCollection();
#endregion
#region Properties
+
+ /// <summary>
+ /// Allow to set properties before configuration
+ /// </summary>
+ public NameValueCollection Properties
+ {
+ set { _configScope.Properties.Add(value); }
+ }
+
/// <summary>
/// Allow to set a custom set accessor factory, see <see cref="ISetAccessorFactory"/>
+ /// before configuration
/// </summary>
public ISetAccessorFactory SetAccessorFactory
{
@@ -308,6 +319,7 @@
/// <summary>
/// Allow to set a custom get accessor factory, see <see cref="IGetAccessorFactory"/>
+ /// before configuration
/// </summary>
public IGetAccessorFactory GetAccessorFactory
{
@@ -316,6 +328,7 @@
/// <summary>
/// Allow to set a custom object factory, see <see cref="IObjectFactory"/>
+ /// before configuration
/// </summary>
public IObjectFactory ObjectFactory
{
@@ -323,7 +336,8 @@
}
/// <summary>
- /// Enable whether or not the validation of configuration document.
+ /// Enable whether or not the validation of configuration document
+ /// before configuration
/// </summary>
public bool ValidateSqlMapConfig
{
@@ -1730,7 +1744,9 @@
foreach(string propertyName in superMap.GetPropertyNameArray())
{
- parameterMap.InsertParameterProperty( index, superMap.GetProperty(propertyName) );
+ ParameterProperty property = superMap.GetProperty(propertyName).Clone();
+ property.Initialize(_configScope, parameterMap.Class);
+ parameterMap.InsertParameterProperty(index, property);
index++;
}
}
@@ -1789,7 +1805,8 @@
// Add parent property
for(int index=0; index< superMap.Properties.Count; index++)
{
- ResultProperty property = superMap.Properties[index];
+ ResultProperty property = superMap.Properties[index].Clone();
+ property.Initialize(_configScope, resultMap.Class);
resultMap.AddResultPropery(property);
}
}
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=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Thu May 18 13:25:03 2006
@@ -378,5 +378,30 @@
}
#endregion
- }
+ #region ICloneable Members
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns>An <see cref="ParameterProperty"/></returns>
+ public ParameterProperty Clone()
+ {
+ ParameterProperty property = new ParameterProperty();
+
+ property.CallBackName = this.CallBackName;
+ property.CLRType = this.CLRType;
+ property.ColumnName = this.ColumnName;
+ property.DbType = this.DbType;
+ property.DirectionAttribute = this.DirectionAttribute;
+ property.NullValue = this.NullValue;
+ property.PropertyName = this.PropertyName;
+ property.Precision = this.Precision;
+ property.Scale = this.Scale;
+ property.Size = this.Size;
+
+ return property;
+ }
+ #endregion
+
+ }
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs Thu May 18 13:25:03 2006
@@ -38,6 +38,7 @@
using IBatisNet.DataMapper.MappedStatements.PropertyStrategy;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
+using IBatisNet.DataMapper.Proxy;
#endregion
@@ -48,7 +49,7 @@
/// </summary>
[Serializable]
[XmlRoot("result", Namespace="http://ibatis.apache.org/mapping")]
- public class ResultProperty
+ public class ResultProperty
{
#region Const
@@ -90,10 +91,21 @@
private bool _isComplexMemberName = false;
[NonSerialized]
private IPropertyStrategy _propertyStrategy = null;
+ [NonSerialized]
+ private ILazyFactory _lazyFactory = null;
#endregion
#region Properties
+ /// <summary>
+ /// The lazy loader factory
+ /// </summary>
+ [XmlIgnore]
+ public ILazyFactory LazyFactory
+ {
+ get { return _lazyFactory; }
+ }
+
/// <summary>
/// Sets or gets the <see cref="IArgumentStrategy"/> used to fill the object property.
/// </summary>
@@ -349,6 +361,11 @@
configScope.ErrorContext.MoreInfo = "Result property '"+_propertyName+"' set the typeHandler attribute.";
_typeHandler = configScope.ResolveTypeHandler( resultClass, _propertyName, _clrType, _dbType);
}
+
+ if (this.IsLazyLoad)
+ {
+ _lazyFactory = new LazyFactoryBuilder().GetLazyFactory(_setAccessor.MemberType);
+ }
}
/// <summary>
@@ -422,6 +439,32 @@
}
#endregion
- }
+
+ #region ICloneable Members
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns>An <see cref="ResultProperty"/></returns>
+ public ResultProperty Clone()
+ {
+ ResultProperty resultProperty = new ResultProperty();
+
+ resultProperty.CLRType = this.CLRType;
+ resultProperty.CallBackName = this.CallBackName;
+ resultProperty.ColumnIndex = this.ColumnIndex;
+ resultProperty.ColumnName = this.ColumnName;
+ resultProperty.DbType = this.DbType;
+ resultProperty.IsLazyLoad = this.IsLazyLoad;
+ resultProperty.NestedResultMapName = this.NestedResultMapName;
+ resultProperty.NullValue = this.NullValue;
+ resultProperty.PropertyName = this.PropertyName;
+ resultProperty.Select = this.Select;
+
+ return resultProperty;
+ }
+
+ #endregion
+ }
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj Thu May 18 13:25:03 2006
@@ -530,6 +530,12 @@
<Compile Include="Mapper.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Proxy\ILazyFactory.cs" />
+ <Compile Include="Proxy\LazyFactoryBuilder.cs" />
+ <Compile Include="Proxy\LazyList.cs" />
+ <Compile Include="Proxy\LazyListFactory.cs" />
+ <Compile Include="Proxy\LazyListGeneric.cs" />
+ <Compile Include="Proxy\LazyListGenericFactory.cs" />
<Compile Include="Proxy\LazyLoadInterceptor.cs" />
<Compile Include="Proxy\LazyLoadProxyFactory.cs" />
<Compile Include="Scope\ConfigurationScope.cs">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Thu May 18 13:25:03 2006
@@ -1033,6 +1033,26 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Proxy\ILazyFactory.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Proxy\LazyFactoryBuilder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Proxy\LazyList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Proxy\LazyListFactory.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Proxy\LazyLoadInterceptor.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/SelectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/SelectStrategy.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/SelectStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/SelectStrategy.cs Thu May 18 13:25:03 2006
@@ -67,7 +67,7 @@
}
#if dotnet2
else if (mapping.MemberType.IsGenericType &&
- mapping.MemberType.GetGenericTypeDefinition() == typeof(IList<>))
+ typeof(IList<>).IsAssignableFrom(mapping.MemberType.GetGenericTypeDefinition()))
{
_selectStrategy = selectGenericListStrategy;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Thu May 18 13:25:03 2006
@@ -612,15 +612,13 @@
using (IDbCommand command = request.IDbCommand)
{
- // TODO: Should we ignore this?, I think so in the case of generics.
if (_statement.ListClass == null)
{
list = new List<T>();
}
else
{
- list = new List<T>();
- //list = _statement.CreateInstanceOfGenericListClass<T>();
+ list = _statement.CreateInstanceOfGenericListClass<T>();
}
using (IDataReader reader = command.ExecuteReader())
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs Thu May 18 13:25:03 2006
@@ -67,7 +67,7 @@
if (mapping.IsLazyLoad)
{
- object values = LazyLoadProxyFactory.Build(selectStatement, keys, target, mapping.SetAccessor);
+ object values = mapping.LazyFactory.CreateProxy(selectStatement, keys, target, mapping.SetAccessor);
mapping.SetAccessor.Set(target, values);
}
else
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs Thu May 18 13:25:03 2006
@@ -65,7 +65,7 @@
if (mapping.IsLazyLoad)
{
- object values = LazyLoadProxyFactory.Build(selectStatement, keys, target, mapping.SetAccessor);
+ object values = mapping.LazyFactory.CreateProxy(selectStatement, keys, target, mapping.SetAccessor);
mapping.SetAccessor.Set(target, values);
}
else
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs?rev=407629&r1=407628&r2=407629&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs Thu May 18 13:25:03 2006
@@ -66,7 +66,7 @@
}
#if dotnet2
else if (mapping.SetAccessor.MemberType.IsGenericType &&
- mapping.SetAccessor.MemberType.GetGenericTypeDefinition() == typeof(IList<>))
+ typeof(IList<>).IsAssignableFrom(mapping.SetAccessor.MemberType.GetGenericTypeDefinition()) )
{
_selectStrategy = selectGenericListStrategy;
}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs?rev=407629&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs Thu May 18 13:25:03 2006
@@ -0,0 +1,49 @@
+#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 IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.Common.Utilities.Objects.Members;
+
+namespace IBatisNet.DataMapper.Proxy
+{
+ /// <summary>
+ /// Contract of an <see cref="ILazyFactory"/>
+ /// </summary>
+ public interface ILazyFactory
+ {
+ /// <summary>
+ /// Create a new proxy instance.
+ /// </summary>
+ /// <param name="mappedStatement">The mapped statement.</param>
+ /// <param name="param">The param.</param>
+ /// <param name="target">The target.</param>
+ /// <param name="setAccessor">The set accessor.</param>
+ /// <returns>Returns a new proxy.</returns>
+ object CreateProxy(IMappedStatement mappedStatement, object param,
+ object target, ISetAccessor setAccessor);
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/ILazyFactory.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs?rev=407629&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs Thu May 18 13:25:03 2006
@@ -0,0 +1,101 @@
+#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;
+#if dotnet2
+using System.Collections.Generic;
+#endif
+using IBatisNet.DataMapper.Exceptions;
+
+namespace IBatisNet.DataMapper.Proxy
+{
+ /// <summary>
+ /// Gets <see cref="ILazyFactory"/> instance.
+ /// </summary>
+ public class LazyFactoryBuilder
+ {
+ IDictionary _factory = new HybridDictionary();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LazyFactoryBuilder"/> class.
+ /// </summary>
+ public LazyFactoryBuilder()
+ {
+ _factory[typeof(IList)] = new LazyListFactory();
+#if dotnet2
+ _factory[typeof(IList<>)] = new LazyListGenericFactory();
+#endif
+ }
+
+
+ /// <summary>
+ /// Register (add) a lazy load Proxy for a type and member type
+ /// </summary>
+ /// <param name="type">The target type which contains the member proxyfied</param>
+ /// <param name="memberName">The member name the proxy must emulate</param>
+ /// <param name="factory">The <see cref="ILazyFactory"/>.</param>
+ public void Register(Type type, string memberName, ILazyFactory factory)
+ {
+ // To use for further used, support for custom proxy
+ }
+
+ /// <summary>
+ /// Get a ILazyLoadProxy for a type, member name
+ /// </summary>
+ /// <param name="type">The target type which contains the member proxyfied</param>
+ /// <returns>Return the ILazyLoadProxy instance</returns>
+ public ILazyFactory GetLazyFactory(Type type)
+ {
+ if (type.IsInterface)
+ {
+#if dotnet2
+ if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(IList<>)) )
+ {
+ return _factory[ type.GetGenericTypeDefinition() ] as ILazyFactory;
+ }
+ else
+#endif
+ if (type == typeof(IList))
+ {
+ return _factory[type] as ILazyFactory;
+ }
+ else
+ {
+ throw new DataMapperException("Cannot proxy others interfaces than IList or IList<>.");
+ }
+ }
+ else
+ {
+ // if you want to proxy concrete classes, there are also two requirements:
+ // the class can not be sealed and only virtual methods can be intercepted.
+ // The reason is that DynamicProxy will create a subclass of your class overriding all methods
+ // so it can dispatch the invocations to the interceptor.
+ return new LazyLoadProxyFactory();
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyFactoryBuilder.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs?rev=407629&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs Thu May 18 13:25:03 2006
@@ -0,0 +1,302 @@
+#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 IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.Common.Utilities.Objects.Members;
+using IBatisNet.Common.Logging;
+using System.Reflection;
+
+namespace IBatisNet.DataMapper.Proxy
+{
+ /// <summary>
+ /// A lazy list
+ /// </summary>
+ [Serializable]
+ public class LazyList : IList
+ {
+ #region Fields
+ private object _param = null;
+ private object _target = null;
+ private ISetAccessor _setAccessor = null;
+ private SqlMapper _sqlMap = null;
+ private string _statementId = string.Empty;
+ private bool _loaded = false;
+ private object _loadLock = new object();
+ private IList _list = null;
+
+ private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ #endregion
+
+ /// <summary>
+ /// Resolve the lazy loading.
+ /// </summary>
+ /// <param name="methodName">Name of the method.</param>
+ private void Load(string methodName)
+ {
+ if (_logger.IsDebugEnabled)
+ {
+ _logger.Debug("Proxyfying call to " + methodName);
+ }
+
+ lock (_loadLock)
+ {
+ if (_loaded == false)
+ {
+ if (_logger.IsDebugEnabled)
+ {
+ _logger.Debug("Proxyfying call, query statement " + _statementId);
+ }
+ _list = _sqlMap.QueryForList(_statementId, _param);
+ _loaded = true;
+ _setAccessor.Set(_target, _list);
+ }
+ }
+
+ if (_logger.IsDebugEnabled)
+ {
+ _logger.Debug("End of proxyfied call to " + methodName);
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="T:LazyList"/> class.
+ /// </summary>
+ /// <param name="mappedSatement">The mapped satement.</param>
+ /// <param name="param">The param.</param>
+ /// <param name="target">The target.</param>
+ /// <param name="setAccessor">The set accessor.</param>
+ public LazyList(IMappedStatement mappedSatement, object param,
+ object target, ISetAccessor setAccessor)
+ {
+ _list = new ArrayList();
+ _param = param;
+ _statementId = mappedSatement.Id;
+ _sqlMap = mappedSatement.SqlMap;
+ _target = target;
+ _setAccessor = setAccessor;
+ }
+
+ #region IList Members
+
+ /// <summary>
+ /// Adds an item to the <see cref="T:System.Collections.IList"></see>.
+ /// </summary>
+ /// <param name="value">The <see cref="T:System.Object"></see> to add to the <see cref="T:System.Collections.IList"></see>.</param>
+ /// <returns>
+ /// The position into which the new element was inserted.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IList"></see> is read-only.-or- The <see cref="T:System.Collections.IList"></see> has a fixed size. </exception>
+ public int Add(object value)
+ {
+ Load("Add");
+ return _list.Add(value);
+ }
+
+ /// <summary>
+ /// Removes all items from the <see cref="T:System.Collections.IList"></see>.
+ /// </summary>
+ /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IList"></see> is read-only. </exception>
+ public void Clear()
+ {
+ Load("Clear");
+ _list.Clear();
+ }
+
+ /// <summary>
+ /// Determines whether the <see cref="T:System.Collections.IList"></see> contains a specific value.
+ /// </summary>
+ /// <param name="value">The <see cref="T:System.Object"></see> to locate in the <see cref="T:System.Collections.IList"></see>.</param>
+ /// <returns>
+ /// true if the <see cref="T:System.Object"></see> is found in the <see cref="T:System.Collections.IList"></see>; otherwise, false.
+ /// </returns>
+ public bool Contains(object value)
+ {
+ Load("Contains");
+ return _list.Contains(value);
+ }
+
+ /// <summary>
+ /// Determines the index of a specific item in the <see cref="T:System.Collections.IList"></see>.
+ /// </summary>
+ /// <param name="value">The <see cref="T:System.Object"></see> to locate in the <see cref="T:System.Collections.IList"></see>.</param>
+ /// <returns>
+ /// The index of value if found in the list; otherwise, -1.
+ /// </returns>
+ public int IndexOf(object value)
+ {
+ Load("IndexOf");
+ return _list.IndexOf(value);
+ }
+
+ /// <summary>
+ /// Inserts an item to the <see cref="T:System.Collections.IList"></see> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index at which value should be inserted.</param>
+ /// <param name="value">The <see cref="T:System.Object"></see> to insert into the <see cref="T:System.Collections.IList"></see>.</param>
+ /// <exception cref="T:System.ArgumentOutOfRangeException">index is not a valid index in the <see cref="T:System.Collections.IList"></see>. </exception>
+ /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IList"></see> is read-only.-or- The <see cref="T:System.Collections.IList"></see> has a fixed size. </exception>
+ /// <exception cref="T:System.NullReferenceException">value is null reference in the <see cref="T:System.Collections.IList"></see>.</exception>
+ public void Insert(int index, object value)
+ {
+ Load("Insert");
+ _list.Insert(index, value);
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the <see cref="T:System.Collections.IList"></see> has a fixed size.
+ /// </summary>
+ /// <value></value>
+ /// <returns>true if the <see cref="T:System.Collections.IList"></see> has a fixed size; otherwise, false.</returns>
+ public bool IsFixedSize
+ {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the <see cref="T:System.Collections.IList"></see> is read-only.
+ /// </summary>
+ /// <value></value>
+ /// <returns>true if the <see cref="T:System.Collections.IList"></see> is read-only; otherwise, false.</returns>
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.IList"></see>.
+ /// </summary>
+ /// <param name="value">The <see cref="T:System.Object"></see> to remove from the <see cref="T:System.Collections.IList"></see>.</param>
+ /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IList"></see> is read-only.-or- The <see cref="T:System.Collections.IList"></see> has a fixed size. </exception>
+ public void Remove(object value)
+ {
+ Load("Remove");
+ _list.Remove(value);
+ }
+
+ /// <summary>
+ /// Removes the <see cref="T:System.Collections.IList"></see> item at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index of the item to remove.</param>
+ /// <exception cref="T:System.ArgumentOutOfRangeException">index is not a valid index in the <see cref="T:System.Collections.IList"></see>. </exception>
+ /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.IList"></see> is read-only.-or- The <see cref="T:System.Collections.IList"></see> has a fixed size. </exception>
+ public void RemoveAt(int index)
+ {
+ Load("RemoveAt");
+ _list.RemoveAt(index);
+ }
+
+ /// <summary>
+ /// Gets or sets the <see cref="T:Object"/> at the specified index.
+ /// </summary>
+ /// <value></value>
+ public object this[int index]
+ {
+ get
+ {
+ Load("this");
+ return _list[index];
+ }
+ set
+ {
+ Load("this");
+ _list[index] = value;
+ }
+ }
+
+ #endregion
+
+ #region ICollection Members
+
+ /// <summary>
+ /// Copies the elements of the <see cref="T:System.Collections.ICollection"></see> to an <see cref="T:System.Array"></see>, starting at a particular <see cref="T:System.Array"></see> index.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="T:System.Array"></see> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"></see>. The <see cref="T:System.Array"></see> must have zero-based indexing.</param>
+ /// <param name="index">The zero-based index in array at which copying begins.</param>
+ /// <exception cref="T:System.ArgumentNullException">array is null. </exception>
+ /// <exception cref="T:System.ArgumentOutOfRangeException">index is less than zero. </exception>
+ /// <exception cref="T:System.ArgumentException">array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source <see cref="T:System.Collections.ICollection"></see> is greater than the available space from index to the end of the destination array. </exception>
+ /// <exception cref="T:System.InvalidCastException">The type of the source <see cref="T:System.Collections.ICollection"></see> cannot be cast automatically to the type of the destination array. </exception>
+ public void CopyTo(Array array, int index)
+ {
+ Load("CopyTo");
+ _list.CopyTo(array, index);
+ }
+
+ /// <summary>
+ /// Gets the number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The number of elements contained in the <see cref="T:System.Collections.ICollection"></see>.</returns>
+ public int Count
+ {
+ get
+ {
+ Load("Count");
+ return _list.Count;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe).
+ /// </summary>
+ /// <value></value>
+ /// <returns>true if access to the <see cref="T:System.Collections.ICollection"></see> is synchronized (thread safe); otherwise, false.</returns>
+ public bool IsSynchronized
+ {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection"></see>.</returns>
+ public object SyncRoot
+ {
+ get { return this; }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ /// <summary>
+ /// Returns an enumerator that iterates through a collection.
+ /// </summary>
+ /// <returns>
+ /// An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.
+ /// </returns>
+ public IEnumerator GetEnumerator()
+ {
+ Load("Add");
+ return _list.GetEnumerator();
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyList.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs?rev=407629&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs Thu May 18 13:25:03 2006
@@ -0,0 +1,57 @@
+#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.Text;
+using IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.Common.Utilities.Objects.Members;
+
+namespace IBatisNet.DataMapper.Proxy
+{
+ /// <summary>
+ /// Implementation of <see cref="ILazyFactory"/> to create proxy for an <see cref="IList"/> element.
+ /// </summary>
+ public class LazyListFactory : ILazyFactory
+ {
+ #region ILazyFactory Members
+
+ /// <summary>
+ /// Create a new proxy instance.
+ /// </summary>
+ /// <param name="mappedStatement">The mapped statement.</param>
+ /// <param name="param">The param.</param>
+ /// <param name="target">The target.</param>
+ /// <param name="setAccessor">The set accessor.</param>
+ /// <returns>Returns a new proxy.</returns>
+ public object CreateProxy(IMappedStatement mappedStatement, object param,
+ object target, ISetAccessor setAccessor)
+ {
+ return new LazyList(mappedStatement, param, target, setAccessor);
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyListFactory.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy