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/08 15:22:15 UTC

svn commit: r405046 [7/7] - in /ibatis/trunk/cs/mapper: IBatisNet.Common.Test/Domain/ IBatisNet.Common.Test/NUnit/CommonTests/Utilities/ IBatisNet.Common/ IBatisNet.Common/Utilities/Objects/ IBatisNet.Common/Utilities/Objects/Members/ IBatisNet.DataAcc...

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,74 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.PropertyStrategy
+{
+	/// <summary>
+	/// <see cref="IPropertyStrategy"/> implementation when a 'select' attribute exists
+	/// on a <see cref="Array"/> <see cref="ResultProperty"/>
+	/// </summary>
+    public sealed class SelectArrayStrategy : IPropertyStrategy
+	{
+		#region IPropertyStrategy members
+
+		///<summary>
+		/// Sets value of the specified <see cref="ResultProperty"/> on the target object
+		/// when a 'select' attribute exists and fills an Array property
+		/// on the <see cref="ResultProperty"/> are empties.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="resultMap">The result map.</param>
+		/// <param name="mapping">The ResultProperty.</param>
+		/// <param name="target">The target.</param>
+		/// <param name="reader">The <see cref="IDataReader"/></param>
+		/// <param name="keys">The keys</param>
+		public void Set(RequestScope request, ResultMap resultMap, 
+			ResultProperty mapping, ref object target, IDataReader reader, object keys)
+		{
+			// Get the select statement
+			IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
+
+			PostBindind postSelect = new PostBindind();
+			postSelect.Statement = selectStatement;
+			postSelect.Keys = keys;
+			postSelect.Target = target;
+			postSelect.ResultProperty = mapping;
+		
+			if (mapping.IsLazyLoad)
+			{
+				throw new NotImplementedException("Lazy load no supported for System.Array property:" + mapping.SetAccessor.Name);
+			}
+			postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForArrayList;
+			request.QueueSelect.Enqueue(postSelect);
+		}
+
+		#endregion
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,86 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Generic;
+using System.Data;
+
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Proxy;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.PropertyStrategy
+{
+    /// <summary>
+    /// <see cref="IPropertyStrategy"/> implementation when a 'select' attribute exists
+    /// on a <see cref="IList"/> <see cref="ResultProperty"/>
+    /// </summary>
+    public sealed class SelectGenericListStrategy : IPropertyStrategy
+    {
+        #region IPropertyStrategy members
+
+        ///<summary>
+        /// Sets value of the specified <see cref="ResultProperty"/> on the target object
+        /// when a 'select' attribute exists and fills an <see cref="IList"/> property
+        /// on the <see cref="ResultProperty"/> are empties.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="resultMap">The result map.</param>
+        /// <param name="mapping">The ResultProperty.</param>
+        /// <param name="target">The target.</param>
+        /// <param name="reader">The current <see cref="IDataReader"/></param>
+        /// <param name="keys">The keys</param>
+        public void Set(RequestScope request, ResultMap resultMap,
+            ResultProperty mapping, ref object target, IDataReader reader, object keys)
+        {
+            // Get the select statement
+            IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
+
+            PostBindind postSelect = new PostBindind();
+            postSelect.Statement = selectStatement;
+            postSelect.Keys = keys;
+            postSelect.Target = target;
+            postSelect.ResultProperty = mapping;
+
+            if (mapping.IsLazyLoad)
+            {
+                object values = LazyLoadProxyFactory.Build(selectStatement, keys, target, mapping.SetAccessor);
+                mapping.SetAccessor.Set(target, values);
+            }
+            else
+            {
+                if (mapping.SetAccessor.MemberType.GetGenericTypeDefinition() == typeof(IList<>))
+                {
+                    postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForGenericIList;
+                }
+                request.QueueSelect.Enqueue(postSelect);
+            }
+
+        }
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,88 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Proxy;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.PropertyStrategy
+{
+	/// <summary>
+	/// <see cref="IPropertyStrategy"/> implementation when a 'select' attribute exists
+	/// on a <see cref="IList"/> <see cref="ResultProperty"/>
+	/// </summary>
+    public sealed class SelectListStrategy : IPropertyStrategy
+	{
+		#region IPropertyStrategy members
+		
+		///<summary>
+		/// Sets value of the specified <see cref="ResultProperty"/> on the target object
+		/// when a 'select' attribute exists and fills an <see cref="IList"/> property
+		/// on the <see cref="ResultProperty"/> are empties.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="resultMap">The result map.</param>
+		/// <param name="mapping">The ResultProperty.</param>
+		/// <param name="target">The target.</param>
+		/// <param name="reader">The current <see cref="IDataReader"/></param>
+		/// <param name="keys">The keys</param>
+		public void Set(RequestScope request, ResultMap resultMap, 
+			ResultProperty mapping, ref object target, IDataReader reader, object keys)
+		{
+			// Get the select statement
+			IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
+
+			PostBindind postSelect = new PostBindind();
+			postSelect.Statement = selectStatement;
+			postSelect.Keys = keys;
+			postSelect.Target = target;
+			postSelect.ResultProperty = mapping;		
+		
+			if (mapping.IsLazyLoad)
+			{
+				object values = LazyLoadProxyFactory.Build(selectStatement, keys, target, mapping.SetAccessor);
+				mapping.SetAccessor.Set(target, values);
+			}
+			else
+			{
+				if (mapping.SetAccessor.MemberType == typeof(IList))
+				{
+					postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForIList;
+				}
+				else
+				{
+					postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForStrongTypedIList;
+				}
+				request.QueueSelect.Enqueue(postSelect);
+			}
+
+		}
+
+		#endregion
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,73 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.PropertyStrategy
+{
+	/// <summary>
+	/// <see cref="IPropertyStrategy"/> implementation when a 'select' attribute exists
+	/// on an <see cref="ResultProperty"/> and the object property is 
+	/// different from an <see cref="Array"/> or an <see cref="IList"/>.
+	/// </summary>
+    public sealed class SelectObjectStrategy : IPropertyStrategy
+	{
+
+		#region IPropertyStrategy members
+
+		///<summary>
+		/// Sets value of the specified <see cref="ResultProperty"/> on the target object
+		/// when a 'select' attribute exists and fills an object property.
+		/// on the <see cref="ResultProperty"/> are empties.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="resultMap">The result map.</param>
+		/// <param name="mapping">The ResultProperty.</param>
+		/// <param name="target">The target.</param>
+		/// <param name="reader">The current <see cref="IDataReader"/></param>
+		/// <param name="keys">The keys</param>
+		public void Set(RequestScope request, ResultMap resultMap, 
+			ResultProperty mapping, ref object target, IDataReader reader, object keys)
+		{
+			// Get the select statement
+			IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
+
+			PostBindind postSelect = new PostBindind();
+			postSelect.Statement = selectStatement;
+			postSelect.Keys = keys;
+			postSelect.Target = target;
+			postSelect.ResultProperty = mapping;
+
+			postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForObject;
+			request.QueueSelect.Enqueue(postSelect);
+		}
+
+		#endregion
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,151 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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;
+#if dotnet2
+using System.Collections.Generic;
+#endif
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Exceptions;
+using IBatisNet.DataMapper.Proxy;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.PropertyStrategy
+{
+	/// <summary>
+	/// <see cref="IPropertyStrategy"/> implementation when a 'select' attribute exists
+	/// on a <see cref="ResultProperty"/>
+	/// </summary>
+	public class SelectStrategy : IPropertyStrategy
+	{
+		private IPropertyStrategy _selectStrategy = null;
+
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SelectStrategy"/> class.
+        /// </summary>
+        /// <param name="mapping">The mapping.</param>
+        /// <param name="selectArrayStrategy">The select array strategy.</param>
+        /// <param name="selectGenericListStrategy">The select generic list strategy.</param>
+        /// <param name="selectListStrategy">The select list strategy.</param>
+        /// <param name="selectObjectStrategy">The select object strategy.</param>
+		public SelectStrategy(ResultProperty mapping,
+            IPropertyStrategy selectArrayStrategy,
+            IPropertyStrategy selectGenericListStrategy,
+            IPropertyStrategy selectListStrategy,
+            IPropertyStrategy selectObjectStrategy)
+		{
+			// Collection object or .NET object			
+			if (mapping.SetAccessor.MemberType.BaseType == typeof(Array))
+			{
+                _selectStrategy = selectArrayStrategy;
+			}
+#if dotnet2
+            else if (mapping.SetAccessor.MemberType.IsGenericType &&
+                 mapping.SetAccessor.MemberType.GetGenericTypeDefinition() == typeof(IList<>)) 
+            {
+                _selectStrategy = selectGenericListStrategy;
+            }
+#endif			
+            // Check if the object to Map implement 'IList' or is IList type
+			// If yes the ResultProperty is map to a IList object
+            else if (typeof(IList).IsAssignableFrom(mapping.SetAccessor.MemberType))
+			{
+                _selectStrategy = selectListStrategy;
+			}
+
+			else // The ResultProperty is map to a .Net object
+			{
+                _selectStrategy = selectObjectStrategy;
+			}
+		}
+	
+		#region IPropertyStrategy members
+
+		///<summary>
+		/// Sets value of the specified <see cref="ResultProperty"/> on the target object
+		/// when a 'select' attribute exists
+		/// on the <see cref="ResultProperty"/> are empties.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="resultMap">The result map.</param>
+		/// <param name="mapping">The ResultProperty.</param>
+		/// <param name="target">The target.</param>
+		/// <param name="reader">The reader.</param>
+		/// <param name="selectKeys">The keys</param>
+		public void Set(RequestScope request, ResultMap resultMap, 
+			ResultProperty mapping, ref object target, IDataReader reader, object selectKeys)
+		{
+			string paramString = mapping.ColumnName;
+			object keys = null;
+			bool wasNull = false;
+
+			#region Finds the select keys.
+			if (paramString.IndexOf(',')>0 || paramString.IndexOf('=')>0) // composite parameters key
+			{
+				IDictionary keyMap = new Hashtable();
+				keys = keyMap;
+				// define which character is seperating fields
+				char[] splitter  = {'=',','};
+
+				string[] paramTab = paramString.Split(splitter);
+				if (paramTab.Length % 2 != 0) 
+				{
+					throw new DataMapperException("Invalid composite key string format in '"+mapping.PropertyName+". It must be: property1=column1,property2=column2,..."); 
+				}
+				IEnumerator enumerator = paramTab.GetEnumerator();
+				while (!wasNull && enumerator.MoveNext()) 
+				{
+					string hashKey = ((string)enumerator.Current).Trim();
+					enumerator.MoveNext();
+					object hashValue = reader.GetValue( reader.GetOrdinal(((string)enumerator.Current).Trim()) );
+
+					keyMap.Add(hashKey, hashValue );
+					wasNull = (hashValue == DBNull.Value);
+				}
+			} 
+			else // single parameter key
+			{
+				keys = reader.GetValue(reader.GetOrdinal(paramString));
+				wasNull = reader.IsDBNull(reader.GetOrdinal(paramString));
+			}
+			#endregion
+
+			if (wasNull) 
+			{
+				// set the value of an object property to null
+                mapping.SetAccessor.Set(target, null);
+			} 
+			else // Collection object or .Net object
+			{
+				_selectStrategy.Set(request, resultMap, mapping, ref target, reader, keys);
+			}		
+		}
+
+		#endregion
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,186 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 397590 $
+ * $Date: 2006-04-29 11:39:42 +0200 (Sat, 29 Apr 2006) $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using System.Reflection;
+using IBatisNet.Common.Logging;
+using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.Common.Utilities.Objects.Members;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.DataExchange;
+using IBatisNet.DataMapper.Exceptions;
+using IBatisNet.DataMapper.MappedStatements.PropertyStrategy;
+using IBatisNet.DataMapper.TypeHandlers;
+
+#endregion
+
+namespace IBatisNet.DataMapper.MappedStatements
+{
+    /// <summary>
+    /// Build a dynamic instance of a ResultMap
+    /// </summary>
+    public class ReaderAutoMapper 
+	{
+		private ResultMap _resultMap = null;
+        private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ReaderAutoMapper"/> class.
+        /// </summary>
+        /// <param name="dataExchangeFactory">The data exchange factory.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+		public ReaderAutoMapper(DataExchangeFactory dataExchangeFactory,
+		                        IDataReader reader,
+			                    ref object resultObject) 
+		{
+        	Type targetType = resultObject.GetType();
+			_resultMap = new ResultMap(dataExchangeFactory);
+			_resultMap.DataExchange = dataExchangeFactory.GetDataExchangeForClass( targetType );
+			try 
+			{
+				// Get all PropertyInfo from the resultObject properties
+				ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(targetType);
+				string[] membersName = reflectionInfo.GetWriteableMemberNames();
+
+				Hashtable propertyMap = new Hashtable();
+				int length = membersName.Length;
+				for (int i = 0; i < length; i++) 
+				{
+                    ISetAccessorFactory setAccessorFactory = dataExchangeFactory.AccessorFactory.SetAccessorFactory;
+                    ISetAccessor setAccessor = setAccessorFactory.CreateSetAccessor(targetType, membersName[i]);
+                    propertyMap.Add(membersName[i].ToUpper(), setAccessor);
+				}
+
+				// Get all column Name from the reader
+				// and build a resultMap from with the help of the PropertyInfo[].
+				DataTable dataColumn = reader.GetSchemaTable();
+				int count = dataColumn.Rows.Count;
+				for (int i = 0; i < count; i++) 
+				{
+					string columnName = dataColumn.Rows[i][0].ToString();
+                    ISetAccessor matchedSetAccessor = propertyMap[columnName.ToUpper()] as ISetAccessor;
+
+					ResultProperty property = new ResultProperty();
+					property.ColumnName = columnName;
+					property.ColumnIndex = i;
+
+					if (resultObject is Hashtable) 
+					{
+						property.PropertyName = columnName;
+						_resultMap.AddResultPropery(property);
+					}
+
+					Type propertyType = null;
+
+                    if (matchedSetAccessor == null)
+					{
+						try
+						{
+							propertyType = ObjectProbe.GetMemberTypeForSetter(resultObject, columnName);
+						}
+						catch
+						{
+							_logger.Error("The column [" + columnName + "] could not be auto mapped to a property on [" + resultObject.ToString() + "]");
+						}
+					}
+					else
+					{
+                        propertyType = matchedSetAccessor.MemberType;
+					}
+
+                    if (propertyType != null || matchedSetAccessor != null) 
+					{
+                        property.PropertyName = (matchedSetAccessor != null ? matchedSetAccessor.Name : columnName);
+                        if (matchedSetAccessor != null)
+						{
+                            property.Initialize(dataExchangeFactory.TypeHandlerFactory, matchedSetAccessor);
+						}
+						else
+						{
+                            property.TypeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
+						}
+
+						property.PropertyStrategy = PropertyStrategyFactory.Get(property);
+						_resultMap.AddResultPropery(property);
+					} 
+				}
+			} 
+			catch (Exception e) 
+			{
+				throw new DataMapperException("Error automapping columns. Cause: " + e.Message, e);
+			}
+		}
+
+
+        /// <summary>
+        /// AutoMap the the <see cref="IDataReader"/> to the result object.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+		public void AutoMapReader(IDataReader reader, ref object resultObject)
+		{
+			for(int index=0; index< _resultMap.Properties.Count; index++)
+
+			{
+				ResultProperty property = _resultMap.Properties[index];
+				_resultMap.SetValueOfProperty( ref resultObject, property, 
+					property.GetDataBaseValue( reader ));
+			}
+		}
+
+	}
+
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,103 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using System.Reflection;
+using IBatisNet.Common.Logging;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation used when implicit 'ResultMap'.
+	/// </summary>
+    public sealed class AutoMapStrategy : IResultStrategy
+    {
+		private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
+
+		/// <summary>
+		/// Auto-map the reader to the result object.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="reader">The reader.</param>
+		/// <param name="resultObject">The result object.</param>
+		private void AutoMapReader(RequestScope request, IDataReader reader,ref object resultObject) 
+		{
+			if (request.Statement.RemapResults)
+			{
+				ReaderAutoMapper readerAutoMapper = new ReaderAutoMapper(request.DataExchangeFactory,
+					reader, 
+					ref resultObject);
+				readerAutoMapper.AutoMapReader( reader, ref resultObject );
+				_logger.Debug("The RemapResults");
+			}
+			else
+			{
+				if (request.MappedStatement.ReaderAutoMapper == null)
+				{
+					lock (request.MappedStatement) 
+					{
+						if (request.MappedStatement.ReaderAutoMapper == null) 
+						{
+							request.MappedStatement.ReaderAutoMapper = new ReaderAutoMapper(
+								request.DataExchangeFactory,
+								reader, 
+								ref resultObject);
+						}
+					}
+				}
+				_logger.Debug("The AutoMapReader");
+				request.MappedStatement.ReaderAutoMapper.AutoMapReader( reader, ref resultObject );				
+			}
+
+		}
+
+
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when ..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+			object outObject = resultObject; 
+
+			if (outObject == null) 
+			{
+				outObject = request.Statement.CreateInstanceOfResultClass();
+			}
+
+            AutoMapReader(request, reader, ref outObject);
+
+			return outObject;
+        }
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/BaseResultStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/BaseResultStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/BaseResultStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/BaseResultStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,29 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.DataMapper.MappedStatements.ResultStrategy
+{
+	
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,76 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Collections;
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// a 'resultClass' attribute is specified and
+	/// the type of the result object is <see cref="IDictionary"/>.
+	/// </summary>
+    public sealed class DictionaryStrategy : IResultStrategy
+    {
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when a 'resultClass' attribute is specified on the statement and
+        /// the 'resultClass' attribute is a <see cref="IDictionary"/>.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+			object outObject = resultObject; 
+
+			if (outObject == null) 
+			{
+				outObject = request.Statement.CreateInstanceOfResultClass();
+			}
+
+			int count = reader.FieldCount;
+			for (int i = 0; i < count; i++) 
+			{
+				ResultProperty property = new ResultProperty();
+				property.PropertyName = "value";
+				property.ColumnIndex = i;
+				property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
+				((IDictionary) outObject).Add(
+					reader.GetName(i), 
+					property.GetDataBaseValue(reader));
+			}   
+     
+			return outObject;
+		}
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/IResultStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/IResultStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/IResultStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/IResultStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,45 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+    /// <summary>
+	/// <see cref="IResultStrategy"/> contract to process the <see cref="IDataReader"/>.
+	/// </summary>
+    public interface IResultStrategy
+    {
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/>.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        object Process(RequestScope request, IDataReader reader, object resultObject);
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,74 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Collections;
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// a 'resultClass' attribute is specified and
+	/// the type of the result object is <see cref="IList"/>.
+	/// </summary>
+    public sealed class ListStrategy : IResultStrategy
+    {
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when a ResultClass is specified on the statement and
+        /// the ResultClass is <see cref="IList"/>.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+			object outObject = resultObject; 
+
+			if (outObject == null) 
+			{
+				outObject = request.Statement.CreateInstanceOfResultClass();
+			}
+
+			int count = reader.FieldCount;
+			for (int i = 0; i < count; i++) 
+			{
+				ResultProperty property = new ResultProperty();
+				property.PropertyName = "value";
+				property.ColumnIndex = i;
+				property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
+				((IList) outObject).Add(property.GetDataBaseValue(reader));
+			}    
+    
+			return outObject;
+		}
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,85 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Collections;
+using System.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// no 'resultClass' attribute is specified.
+	/// </summary>
+    public sealed class ObjectStrategy : IResultStrategy
+    {
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+			object outObject = resultObject; 
+
+			if (reader.FieldCount == 1)
+			{
+				ResultProperty property = new ResultProperty();
+				property.PropertyName = "value";
+				property.ColumnIndex = 0;
+				property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(0));
+				outObject = property.GetDataBaseValue(reader);
+			}
+			else if (reader.FieldCount > 1)
+			{
+				object[] newOutObject = new object[reader.FieldCount];
+				int count = reader.FieldCount;
+				for (int i = 0; i < count; i++) 
+				{
+					ResultProperty property = new ResultProperty();
+					property.PropertyName = "value";
+					property.ColumnIndex = i;
+					property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
+					newOutObject[i] = property.GetDataBaseValue(reader);
+				}
+
+				outObject = newOutObject;
+			}
+			else
+			{
+				// do nothing if 0 fields
+			}   
+     
+			return outObject;
+		}
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultClassStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultClassStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultClassStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultClassStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,92 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Collections;
+using System.Data;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// a 'resultClass' attribute is specified.
+	/// </summary>
+	public class ResultClassStrategy : IResultStrategy
+	{
+		private static IResultStrategy _simpleTypeStrategy = null;
+		private static IResultStrategy _dictionaryStrategy = null;
+		private static IResultStrategy _listStrategy = null;
+		private static IResultStrategy _autoMapStrategy = null;
+
+		/// <summary>
+		/// Initializes a new instance of the <see cref="ResultClassStrategy"/> class.
+		/// </summary>
+		public ResultClassStrategy()
+		{
+			_simpleTypeStrategy = new SimpleTypeStrategy();
+			_dictionaryStrategy = new DictionaryStrategy();
+			_listStrategy = new ListStrategy();
+			_autoMapStrategy = new AutoMapStrategy();
+		}
+
+        #region IResultStrategy Members
+
+		/// <summary>
+		/// Processes the specified <see cref="IDataReader"/>.
+		/// </summary>
+		/// <param name="request">The request.</param>
+		/// <param name="reader">The reader.</param>
+		/// <param name="resultObject">The result object.</param>
+		public object Process(RequestScope request, IDataReader reader, object resultObject)
+		{
+			object outObject = resultObject; 
+
+			if (outObject == null) 
+			{
+				outObject = request.Statement.CreateInstanceOfResultClass();
+			}
+
+			// Check if the ResultClass is a 'primitive' Type
+			if (request.DataExchangeFactory.TypeHandlerFactory.IsSimpleType(request.Statement.ResultClass))
+			{
+				return _simpleTypeStrategy.Process(request, reader, resultObject);
+			}
+			else if (outObject is IDictionary) 
+			{
+				return _dictionaryStrategy.Process(request, reader, resultObject);
+			}
+			else if (outObject is IList) 
+			{
+				return _listStrategy.Process(request, reader, resultObject);
+			}
+			else
+			{
+				return _autoMapStrategy.Process(request, reader, resultObject);
+			}
+		}
+
+		#endregion
+	}
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultMapStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultMapStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultMapStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultMapStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,81 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// a 'resultMap' attribute is specified.
+	/// </summary>
+    public sealed class ResultMapStrategy : BaseStrategy, IResultStrategy  
+    {
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when a ResultMap is specified on the statement.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+            object outObject = resultObject; 
+
+        	ResultMap resultMap = request.GetResultMap(reader);
+            if (outObject == null)
+            {
+                object[] parameters = null;
+                if (resultMap.Parameters.Count > 0)
+                {
+                    parameters = new object[resultMap.Parameters.Count];
+                    // Fill parameters array
+                    for (int index = 0; index < resultMap.Parameters.Count; index++)
+                    {
+                        ResultProperty resultProperty = resultMap.Parameters[index];
+                        parameters[index] = resultProperty.ArgumentStrategy.GetValue(request, resultMap, resultProperty, ref reader, null);
+                    }
+                }
+
+                outObject = resultMap.CreateInstanceOfResult(parameters);
+            }
+
+            // For each Property in the ResultMap, set the property in the object 
+            for (int index = 0; index < resultMap.Properties.Count; index++)
+            {
+                ResultProperty property = resultMap.Properties[index];
+                property.PropertyStrategy.Set(request, resultMap, property, ref outObject, reader, null);
+            }
+
+			return outObject;
+        }
+
+        #endregion
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultStrategyFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultStrategyFactory.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultStrategyFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultStrategyFactory.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,74 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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 IBatisNet.DataMapper.Configuration.Statements;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// Factory to get <see cref="IResultStrategy"/> implementation.
+	/// </summary>
+    public class ResultStrategyFactory
+    {
+		private static IResultStrategy _resultClassStrategy = null;
+		private static IResultStrategy _resultMapStrategy = null;
+		private static IResultStrategy _objectStrategy = null;
+
+		/// <summary>
+		/// Initializes the <see cref="ResultStrategyFactory"/> class.
+		/// </summary>
+		static ResultStrategyFactory()
+		{
+			_resultMapStrategy = new ResultMapStrategy();
+			_resultClassStrategy = new ResultClassStrategy();
+			_objectStrategy = new ObjectStrategy();
+		}
+
+		/// <summary>
+		/// Finds the <see cref="IResultStrategy"/>.
+		/// </summary>
+		/// <param name="statement">The statement.</param>
+		/// <returns>The <see cref="IResultStrategy"/></returns>
+		public static IResultStrategy Get(IStatement statement)
+		{
+			// If there's an ResultMap, use it
+			if (statement.ResultMap != null) 
+			{
+				return _resultMapStrategy;
+			} 
+			else // else try to use a ResultClass
+			{
+				if (statement.ResultClass != null) 
+				{
+					return _resultClassStrategy;
+				}
+				else
+				{
+					return _objectStrategy;
+				}
+			}
+		}
+    }
+}

Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/SimpleTypeStrategy.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/SimpleTypeStrategy.cs?rev=405046&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/SimpleTypeStrategy.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/SimpleTypeStrategy.cs Mon May  8 06:21:44 2006
@@ -0,0 +1,79 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
+ * 
+ * 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.Data;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.MappedStatements.PropertyStrategy;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.MappedStatements.ResultStrategy
+{
+	/// <summary>
+	/// <see cref="IResultStrategy"/> implementation when 
+	/// a 'resultClass' attribute is specified and
+	/// the type of the result object is primitive.
+	/// </summary>
+    public sealed class SimpleTypeStrategy : IResultStrategy
+    {
+        #region IResultStrategy Members
+
+        /// <summary>
+        /// Processes the specified <see cref="IDataReader"/> 
+        /// when a ResultClass is specified on the statement and
+        /// the ResultClass is a SimpleType.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="reader">The reader.</param>
+        /// <param name="resultObject">The result object.</param>
+        public object Process(RequestScope request, IDataReader reader, object resultObject)
+        {
+			object outObject = resultObject; 
+
+			if (outObject == null) 
+			{
+				outObject = request.Statement.CreateInstanceOfResultClass();
+			}
+
+			// Create a ResultMap
+			ResultMap resultMap = new ResultMap(request.DataExchangeFactory);
+
+			// Create a ResultProperty
+			ResultProperty property = new ResultProperty();
+			property.PropertyName = "value";
+			property.ColumnIndex = 0;
+			property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(outObject.GetType());
+			property.PropertyStrategy = PropertyStrategyFactory.Get(property);
+			
+			resultMap.AddResultPropery(property);
+			resultMap.DataExchange = request.DataExchangeFactory.GetDataExchangeForClass( typeof(int) );// set the PrimitiveDataExchange
+
+			property.PropertyStrategy.Set(request, resultMap, property, ref outObject, reader, null); 
+      
+			return outObject;
+		}
+
+        #endregion
+    }
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadInterceptor.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadInterceptor.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadInterceptor.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadInterceptor.cs Mon May  8 06:21:44 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Revision: 374175 $
- * $LastChangedDate: 2006-03-22 22:39:21 +0100 (mer., 22 mars 2006) $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
  * $LastChangedBy: gbayon $
  * 
  * iBATIS.NET Data Mapper
@@ -52,7 +52,7 @@
 		#region Fields
 		private object _param = null;
 		private object _target = null;
-		private IMemberAccessor _memberAccessor= null;
+		private ISetAccessor _setAccessor= null;
 		private SqlMapper _sqlMap = null;
 		private string _statementName = string.Empty;
 		private bool _loaded = false;
@@ -79,16 +79,16 @@
 		/// </summary>
 		/// <param name="mappedSatement">The mapped statement used to build the list</param>
 		/// <param name="param">The parameter object used to build the list</param>
-		/// <param name="memberAccessor">The proxified member accessor.</param>
+		/// <param name="setAccessor">The proxified member accessor.</param>
 		/// <param name="target">The target object which contains the property proxydied.</param>
-		internal LazyLoadInterceptor(IMappedStatement mappedSatement, object param, 
-			object target, IMemberAccessor memberAccessor)
+		internal LazyLoadInterceptor(IMappedStatement mappedSatement, object param,
+            object target, ISetAccessor setAccessor)
 		{
 			_param = param;
 			_statementName = mappedSatement.Id;
 			_sqlMap = mappedSatement.SqlMap;
-			_target = target; 
-			_memberAccessor = memberAccessor;
+			_target = target;
+            _setAccessor = setAccessor;
 		}		
 		#endregion
 
@@ -117,7 +117,7 @@
 					}
 					_innerList = _sqlMap.QueryForList(_statementName, _param);
 					_loaded = true;
-					_memberAccessor.Set(_target, _innerList);
+                    _setAccessor.Set(_target, _innerList);
 				}
 			}
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadProxyFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadProxyFactory.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadProxyFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Proxy/LazyLoadProxyFactory.cs Mon May  8 06:21:44 2006
@@ -1,11 +1,11 @@
 #region Apache Notice
 /*****************************************************************************
- * $Header: $
- * $Revision: 391784 $
- * $Date: 2006-04-05 22:23:27 +0200 (mer., 05 avr. 2006) $
+ * $Revision: 374175 $
+ * $LastChangedDate: 2006-04-25 19:40:27 +0200 (mar., 25 avr. 2006) $
+ * $LastChangedBy: gbayon $
  * 
  * iBATIS.NET Data Mapper
- * Copyright (C) 2004 - Gilles Bayon
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
  *  
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,37 +56,37 @@
 		/// <summary>
 		/// Builds the specified lazy load proxy.
 		/// </summary>
-		/// <param name="mappedStatement">The mapped statement used to build the lazy loaded object.</param>
+        /// <param name="selectStatement">The mapped statement used to build the lazy loaded object.</param>
 		/// <param name="param">The parameter object used to build lazy loaded object.</param>
 		/// <param name="target">The target object which contains the property proxydied..</param>
-		/// <param name="memberAccessor">The proxified member accessor.</param>
-		/// <returns></returns>
-		public static object Build(IMappedStatement mappedStatement, object param, 
-			object target, IMemberAccessor memberAccessor)
+        /// <param name="setAccessor">The proxified member accessor.</param>
+		/// <returns>Return a proxy object</returns>
+		public static object Build(IMappedStatement selectStatement, object param, 
+			object target, ISetAccessor setAccessor)
 		{
 			object proxy = null;
-			Type typeProxified = memberAccessor.MemberType; 
-	
-			bool isIList = typeof(IList).IsAssignableFrom(memberAccessor.MemberType) || memberAccessor.MemberType.IsSubclassOf(typeof(IList));
-			Type returnedTypeByStatement = LazyLoadProxyFactory.GetTypeReturnedByStatemet(mappedStatement, isIList); 
+			Type typeProxified = setAccessor.MemberType;
+
+            bool isIList = typeof(IList).IsAssignableFrom(setAccessor.MemberType) || setAccessor.MemberType.IsSubclassOf(typeof(IList));
+			Type returnedTypeByStatement = LazyLoadProxyFactory.GetTypeReturnedByStatemet(selectStatement, isIList); 
 	
 			//Test if the result of the lazy load is assigable to property, test now load time instead
 			//wait to error when the method of proxy are called
 			if (typeProxified.IsAssignableFrom(returnedTypeByStatement) == false)
 			{
-				throw new DataMapperException("Error building LazyLoad proxy for " + target.GetType() + "." + memberAccessor.Name + " can not assing " + typeProxified + " to " + returnedTypeByStatement);
+                throw new DataMapperException("Error building LazyLoad proxy for " + target.GetType() + "." + setAccessor.Name + " can not assing " + typeProxified + " to " + returnedTypeByStatement);
 			}
 
 			//Build the proxy
-			IInterceptor handler = new LazyLoadInterceptor(mappedStatement, param, target, memberAccessor);
+            IInterceptor handler = new LazyLoadInterceptor(selectStatement, param, target, setAccessor);
 			if (isIList)
 			{
 				if (_logger.IsDebugEnabled) 
 				{
-					_logger.Debug(string.Format("Statement '{0}', create list proxy for member {1}.", mappedStatement.Id ,memberAccessor.MemberType));
+                    _logger.Debug(string.Format("Statement '{0}', create list proxy for member {1}.", selectStatement.Id, setAccessor.MemberType));
 				}
 
-				if (mappedStatement.Statement.ListClass == null)
+				if (selectStatement.Statement.ListClass == null)
 				{
 					 proxy = ProxyGeneratorFactory.GetProxyGenerator().CreateProxy(typeof(IList), handler, new ArrayList());
 				}

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Mon May  8 06:21:44 2006
@@ -88,22 +88,6 @@
 
 		#region Properties
 
-        /// <summary>
-        /// The factory for object
-        /// </summary>
-        public IObjectFactory ObjectFactory
-        {
-            get { return _sqlMapper.ObjectFactory; }
-        }
-
-        /// <summary>
-        /// The factory which build MemberAccessorFactory
-        /// </summary>
-        public IMemberAccessorFactory MemberAccessorFactory
-        {
-            get { return _sqlMapper.MemberAccessorFactory; }
-        }
-
 		/// <summary>
 		/// XmlNamespaceManager
 		/// </summary>
@@ -150,13 +134,6 @@
 			get { return _sqlMapper; }
 		}
 
-		/// <summary>
-		/// The current TypeHandlerFactory
-		/// </summary>
-		public TypeHandlerFactory TypeHandlerFactory
-		{
-			get { return _sqlMapper.TypeHandlerFactory; }
-		}
 
 		/// <summary>
 		/// A factory for DataExchange objects
@@ -295,21 +272,21 @@
 			ITypeHandler handler = null;
 			if (clazz==null)
 			{
-				handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
+                handler = this.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler();
 			}
 			else if (typeof(IDictionary).IsAssignableFrom(clazz)) 
 			{
 				// IDictionary
 				if (clrType ==null ||clrType.Length == 0) 
 				{
-					handler = this.TypeHandlerFactory.GetUnkownTypeHandler(); 
+                    handler = this.DataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler(); 
 				} 
 				else 
 				{
 					try 
 					{
 						Type type = Resources.TypeForName(clrType);
-						handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+                        handler = this.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
 					} 
 					catch (Exception e) 
 					{
@@ -321,10 +298,10 @@
                     }
 				}
 			}
-			else if (this.TypeHandlerFactory.GetTypeHandler(clazz, dbType) != null) 
+            else if (this.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(clazz, dbType) != null) 
 			{
 				// Primitive
-				handler = this.TypeHandlerFactory.GetTypeHandler(clazz, dbType);
+                handler = this.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(clazz, dbType);
 			}
 			else 
 			{
@@ -332,14 +309,14 @@
 				if (clrType ==null || clrType.Length == 0) 
 				{
 					Type type = ObjectProbe.GetMemberTypeForGetter(clazz, propertyName);
-					handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+                    handler = this.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
 				} 
 				else 
 				{
 					try 
 					{
 						Type type = Resources.TypeForName(clrType);
-						handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
+                        handler = this.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
 					} 
 					catch (Exception e) 
 					{

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IScope.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IScope.cs Mon May  8 06:21:44 2006
@@ -35,25 +35,11 @@
 	/// </summary>
 	public interface IScope
 	{
+
 		/// <summary>
 		///  Get the error context
 		/// </summary>
 		ErrorContext ErrorContext { get; }
-
-		/// <summary>
-		/// The current TypeHandlerFactory
-		/// </summary>
-		TypeHandlerFactory TypeHandlerFactory { get; }
-
-		/// <summary>
-		/// The factory which build MemberAccessorFactory
-		/// </summary>
-		IMemberAccessorFactory MemberAccessorFactory { get; }
-
-		/// <summary>
-		/// The factory for object
-		/// </summary>
-		IObjectFactory ObjectFactory { get; }
 
 		/// <summary>
 		/// The factory for DataExchange objects

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs Mon May  8 06:21:44 2006
@@ -36,6 +36,7 @@
 using IBatisNet.DataMapper.Configuration.ResultMapping;
 using IBatisNet.DataMapper.Configuration.Statements;
 using IBatisNet.DataMapper.DataExchange;
+using IBatisNet.DataMapper.MappedStatements;
 using IBatisNet.DataMapper.TypeHandlers;
 
 #endregion
@@ -48,27 +49,44 @@
 	public class RequestScope : IScope
 	{
 		#region Fields
-		
+
+		private IStatement _statement = null ;
 		private ErrorContext _errorContext = null;
 		private ParameterMap _parameterMap = null;
-		private ResultMap _resultMap = null;
 		private PreparedStatement _preparedStatement = null;
 		private IDbCommand _command = null;
 		private Queue _selects = new Queue();
 		bool _rowDataFound= false;
 		private static long _nextId = 0;
 		private long _id = 0;
-		private TypeHandlerFactory _typeHandlerFactory = null;
-		private IMemberAccessorFactory _memberAccessorFactory = null;
 		private DataExchangeFactory _dataExchangeFactory = null;
-		private IObjectFactory _objectFactory = null;
 		private IDalSession _session = null;
+		private IMappedStatement _mappedStatement = null;
+
 		#endregion
 	
 		#region Properties
 
 		/// <summary>
-		///  The current session
+		///  The current <see cref="IMappedStatement"/>.
+		/// </summary>
+		public IMappedStatement MappedStatement 
+		{
+			set { _mappedStatement = value; }
+			get { return _mappedStatement; }
+		}
+
+		/// <summary>
+		/// Gets the current <see cref="IStatement"/>.
+		/// </summary>
+		/// <value>The statement.</value>
+		public IStatement Statement
+		{
+			get{ return _statement; }
+		}
+
+		/// <summary>
+		///  The current <see cref="IDalSession"/>.
 		/// </summary>
 		public IDalSession Session
 		{
@@ -76,7 +94,7 @@
 		}
 
 		/// <summary>
-		///  The IDbCommand to execute
+		///  The <see cref="IDbCommand"/> to execute
 		/// </summary>
 		public IDbCommand IDbCommand
 		{
@@ -103,25 +121,24 @@
 		}
 
 		/// <summary>
-		/// The ResultMap used by this request.
+		/// The <see cref="ResultMap"/> used by this request.
 		/// </summary>
 		public ResultMap ResultMap
 		{
-			get { return _resultMap; }
-			set { _resultMap = value; }
+			get { return _statement.ResultMap; }
 		}
 
 		/// <summary>
-		/// The parameterMap used by this request.
+		/// The <see cref="ParameterMap"/> used by this request.
 		/// </summary>
 		public ParameterMap ParameterMap
 		{
-			get { return _parameterMap; }
 			set { _parameterMap = value; }
+			get { return _parameterMap; }
 		}
 
 		/// <summary>
-		/// The PreparedStatement used by this request.
+		/// The <see cref="PreparedStatement"/> used by this request.
 		/// </summary>
 		public PreparedStatement PreparedStatement
 		{
@@ -138,24 +155,20 @@
         /// <summary>
         /// Initializes a new instance of the <see cref="RequestScope"/> class.
         /// </summary>
-        /// <param name="typeHandlerFactory">The type handler factory.</param>
-        /// <param name="memberAccessorFactory">The member accessor factory.</param>
-        /// <param name="objectFactory">The object factory.</param>
         /// <param name="dataExchangeFactory">The data exchange factory.</param>
         /// <param name="session">The session.</param>
-		public RequestScope(TypeHandlerFactory typeHandlerFactory, 
-			IMemberAccessorFactory memberAccessorFactory,
-			IObjectFactory objectFactory,
+        /// <param name="statement">The statement</param>
+		public RequestScope(
 			DataExchangeFactory dataExchangeFactory,
-            IDalSession session
+            IDalSession session,
+			IStatement statement
             )
 		{
 			_errorContext = new ErrorContext();
 
+			_statement = statement;
+			_parameterMap = statement.ParameterMap;
             _session = session;
-			_objectFactory = objectFactory;
-			_typeHandlerFactory = typeHandlerFactory;
-			_memberAccessorFactory = memberAccessorFactory;
 			_dataExchangeFactory = dataExchangeFactory;
 			 _id = GetNextId();
 		}
@@ -196,7 +209,7 @@
 		/// <returns>the resultMap to use</returns>
 		public ResultMap GetResultMap(IDataReader dataReader)
 		{
-			return _resultMap.ResolveSubMap(dataReader);
+			return _statement.ResultMap.ResolveSubMap(dataReader);
 		}
 
 		/// <summary>
@@ -213,14 +226,6 @@
 		#region IScope Members
 
 		/// <summary>
-		/// The factory for object
-		/// </summary>
-		public IObjectFactory ObjectFactory
-		{
-			get{ return _objectFactory; }
-		}
-
-		/// <summary>
 		/// A factory for DataExchange objects
 		/// </summary>
 		public DataExchangeFactory DataExchangeFactory
@@ -228,22 +233,6 @@
 			get { return _dataExchangeFactory; }
 		}		
 		
-		/// <summary>
-		/// The current TypeHandlerFactory
-		/// </summary>
-		public TypeHandlerFactory TypeHandlerFactory
-		{
-			get { return _typeHandlerFactory; }
-		}
-
-		/// <summary>
-		/// The factory which build MemberAccessorFactory
-		/// </summary>
-		public IMemberAccessorFactory MemberAccessorFactory
-		{
-			get { return _memberAccessorFactory; }
-		}
-
 		/// <summary>
 		///  Get the request's error context
 		/// </summary>

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=405046&r1=405045&r2=405046&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Mon May  8 06:21:44 2006
@@ -1,12 +1,12 @@
 
 #region Apache Notice
 /*****************************************************************************
- * $Header: $
  * $Revision$
- * $Date$
+ * $LastChangedDate$
+ * $LastChangedBy$
  * 
  * iBATIS.NET Data Mapper
- * Copyright (C) 2004 - Gilles Bayon
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
  *  
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -106,7 +106,7 @@
 		/// </summary>
 		private SessionHolder _sessionHolder = null;
         private IObjectFactory _objectFactory = null;
-        private IMemberAccessorFactory _memberAccessorFactory = null;
+        private AccessorFactory _accessorFactory = null;
         private DataExchangeFactory _dataExchangeFactory = null;
 		#endregion
 
@@ -157,7 +157,7 @@
 		}
 
         /// <summary>
-        /// The factory for object
+        /// The meta factory for object factory
         /// </summary>
         public IObjectFactory ObjectFactory
         {
@@ -165,11 +165,11 @@
         }
 
         /// <summary>
-        /// The factory which build IMemberAccessor
+        /// The factory which build <see cref="IAccessor"/>
         /// </summary>
-        public IMemberAccessorFactory MemberAccessorFactory
+        public AccessorFactory AccessorFactory
         {
-            get { return _memberAccessorFactory; }
+            get { return _accessorFactory; }
         }
 
 		/// <summary>
@@ -184,17 +184,21 @@
 		#endregion
 
 		#region Constructor (s) / Destructor
-		/// <summary>
-		/// Create a new SqlMap
-		/// </summary>
-        /// <param name="objectFactory"></param>
-        /// <param name="memberAccessorFactory"></param>
-        internal SqlMapper(IObjectFactory objectFactory, IMemberAccessorFactory memberAccessorFactory) 
+
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SqlMapper"/> class.
+        /// </summary>
+        /// <param name="objectFactory">The object factory.</param>
+        /// <param name="accessorFactory">The accessor factory.</param>
+        internal SqlMapper(IObjectFactory objectFactory,
+            AccessorFactory accessorFactory) 
 		{
             _typeHandlerFactory = new TypeHandlerFactory();
             _objectFactory = objectFactory;
-            _memberAccessorFactory = memberAccessorFactory;
-            _dataExchangeFactory = new DataExchangeFactory(_typeHandlerFactory, _objectFactory, _memberAccessorFactory);
+            _accessorFactory = accessorFactory;
+
+            _dataExchangeFactory = new DataExchangeFactory(_typeHandlerFactory, _objectFactory, accessorFactory);
 			_id = HashCodeProvider.GetIdentityHashCode(this).ToString();
 			_sessionHolder = new SessionHolder(_id);
 		}
@@ -1446,15 +1450,15 @@
 		/// <summary>
 		/// Gets a MappedStatement by name
 		/// </summary>
-		/// <param name="name"> The name of the statement</param>
+		/// <param name="id"> The id of the statement</param>
 		/// <returns> The MappedStatement</returns>
-		public IMappedStatement GetMappedStatement(string name) 
+		public IMappedStatement GetMappedStatement(string id) 
 		{
-			if (_mappedStatements.Contains(name) == false) 
+			if (_mappedStatements.Contains(id) == false) 
 			{
-				throw new DataMapperException("This SQL map does not contain a MappedStatement named " + name);
+				throw new DataMapperException("This SQL map does not contain a MappedStatement named " + id);
 			}
-			return (IMappedStatement) _mappedStatements[name];
+			return (IMappedStatement) _mappedStatements[id];
 		}
 
 		/// <summary>