Author: gbayon
Date: Tue Apr 11 21:21:03 2006
New Revision: 393376
URL: http://svn.apache.org/viewcvs?rev=393376&view=rev
Log:
-Imrpovement
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
(with props)
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=393376&r1=393375&r2=393376&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
Tue Apr 11 21:21:03 2006
@@ -873,9 +873,9 @@
_configScope.ErrorContext.Activity = "Resolve
'resultMap' attribute on Result Property";
ResultMap resultMap = (ResultMap)entry.Value;
- foreach(DictionaryEntry item in
resultMap.ColumnsToPropertiesMap)
+ for(int index=0; index<
resultMap.Properties.Count; index++)
{
- ResultProperty result =
(ResultProperty)item.Value;
+ ResultProperty result =
resultMap.Properties[index];
if(result.NestedResultMapName.Length >0)
{
result.NestedResultMap =
_configScope.SqlMapper.GetResultMap(result.NestedResultMapName);
@@ -1722,9 +1722,9 @@
}
// Add parent property
- foreach(DictionaryEntry dicoEntry in
superMap.ColumnsToPropertiesMap)
+ for(int index=0; index<
superMap.Properties.Count; index++)
{
- ResultProperty property =
(ResultProperty)dicoEntry.Value;
+ ResultProperty property =
superMap.Properties[index];
resultMap.AddResultPropery(property);
}
}
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs?rev=393376&r1=393375&r2=393376&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
Tue Apr 11 21:21:03 2006
@@ -39,7 +39,7 @@
/// <summary>
- /// ead-only property describing how many elements are in the
Collection.
+ /// Read-only property describing how many elements are in the
Collection.
/// </summary>
public int Count
{
@@ -48,7 +48,7 @@
/// <summary>
- /// Constructs a ArrayList. The list is initially empty and has
a capacity
+ /// Constructs a ParameterProperty collection. The list is
initially empty and has a capacity
/// of zero. Upon adding the first element to the list the
capacity is
/// increased to 8, and then increased in multiples of two as
required.
/// </summary>
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=393376&r1=393375&r2=393376&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
Tue Apr 11 21:21:03 2006
@@ -27,7 +27,6 @@
#region Using
using System;
-using System.Collections;
using System.Data;
using System.Xml;
using System.Xml.Serialization;
@@ -76,7 +75,7 @@
private Type _class = null;
//(columnName, property)
[NonSerialized]
- private Hashtable _columnsToPropertiesMap = new Hashtable();
+ private ResultPropertyCollection _properties = new
ResultPropertyCollection();
[NonSerialized]
private Discriminator _discriminator = null;
[NonSerialized]
@@ -112,12 +111,12 @@
}
/// <summary>
- /// The collection of result properties.
+ /// The collection of ResultProperty.
/// </summary>
[XmlIgnore]
- public Hashtable ColumnsToPropertiesMap
+ public ResultPropertyCollection Properties
{
- get { return _columnsToPropertiesMap; }
+ get { return _properties; }
}
/// <summary>
@@ -304,7 +303,7 @@
/// <param name="property">The property to add.</param>
public void AddResultPropery(ResultProperty property)
{
- _columnsToPropertiesMap.Add( property.PropertyName,
property );
+ _properties.Add( property );
}
/// <summary>
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs?rev=393376&view=auto
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
(added)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
Tue Apr 11 21:21:03 2006
@@ -0,0 +1,250 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+
********************************************************************************/
+#endregion
+
+using System;
+
+namespace IBatisNet.DataMapper.Configuration.ResultMapping
+{
+ /// <summary>
+ /// A ResultProperty Collection.
+ /// </summary>
+ public class ResultPropertyCollection
+ {
+ private const int _defaultCapacity = 8;
+ private const int _capacityMultiplier = 2;
+ private int _count = 0;
+ private ResultProperty[] _innerList = null;
+
+
+ /// <summary>
+ /// ead-only property describing how many elements are in the
Collection.
+ /// </summary>
+ public int Count
+ {
+ get { return _count; }
+ }
+
+
+ /// <summary>
+ /// Constructs a ResultPropertyCollection. The list is
initially empty and has a capacity
+ /// of zero. Upon adding the first element to the list the
capacity is
+ /// increased to 8, and then increased in multiples of two as
required.
+ /// </summary>
+ public ResultPropertyCollection()
+ {
+ _innerList = new ResultProperty[_defaultCapacity];
+ _count = 0;
+ }
+
+ /// <summary>
+ /// Constructs a ResultPropertyCollection with a given initial
capacity.
+ /// The list is initially empty, but will have room for the
given number of elements
+ /// before any reallocations are required.
+ /// </summary>
+ /// <param name="capacity">The initial capacity of the
list</param>
+ public ResultPropertyCollection(int capacity)
+ {
+ if (capacity < 0)
+ {
+ throw new
ArgumentOutOfRangeException("Capacity", "The size of the list must be >0.");
+ }
+ _innerList = new ResultProperty[capacity];
+ }
+
+ /// <summary>
+ /// Length of the collection
+ /// </summary>
+ public int Length
+ {
+ get{ return _innerList.Length; }
+ }
+
+
+ /// <summary>
+ /// Sets or Gets the ResultProperty at the given index.
+ /// </summary>
+ public ResultProperty this[int index]
+ {
+ get
+ {
+ if (index < 0 || index >= _count)
+ {
+ throw new
ArgumentOutOfRangeException("index");
+ }
+ return _innerList[index];
+ }
+ set
+ {
+ if (index < 0 || index >= _count)
+ {
+ throw new
ArgumentOutOfRangeException("index");
+ }
+ _innerList[index] = value;
+ }
+ }
+
+
+ /// <summary>
+ /// Add an ResultProperty
+ /// </summary>
+ /// <param name="value"></param>
+ /// <returns>Index</returns>
+ public int Add(ResultProperty value)
+ {
+ Resize(_count + 1);
+ int index = _count++;
+ _innerList[index] = value;
+
+ return index;
+ }
+
+
+ /// <summary>
+ /// Add a list of ResultProperty to the collection
+ /// </summary>
+ /// <param name="value"></param>
+ public void AddRange(ResultProperty[] value)
+ {
+ for (int i = 0; i < value.Length; i++)
+ {
+ Add(value[i]);
+ }
+ }
+
+
+ /// <summary>
+ /// Add a list of ResultProperty to the collection
+ /// </summary>
+ /// <param name="value"></param>
+ public void AddRange(ResultPropertyCollection value)
+ {
+ for (int i = 0; i < value.Length; i++)
+ {
+ Add(value[i]);
+ }
+ }
+
+
+ /// <summary>
+ /// Indicate if a ResultProperty is in the collection
+ /// </summary>
+ /// <param name="value">A ResultProperty</param>
+ /// <returns>True fi is in</returns>
+ public bool Contains(ResultProperty value)
+ {
+ for (int i = 0; i < _count; i++)
+ {
+
if(_innerList[i].PropertyName==value.PropertyName)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /// <summary>
+ /// Insert a ResultProperty in the collection.
+ /// </summary>
+ /// <param name="index">Index where to insert.</param>
+ /// <param name="value">A ResultProperty</param>
+ public void Insert(int index, ResultProperty value)
+ {
+ if (index < 0 || index > _count)
+ {
+ throw new ArgumentOutOfRangeException("index");
+ }
+
+ Resize(_count + 1);
+ Array.Copy(_innerList, index, _innerList, index + 1,
_count - index);
+ _innerList[index] = value;
+ _count++;
+ }
+
+
+ /// <summary>
+ /// Remove a ResultProperty of the collection.
+ /// </summary>
+ public void Remove(ResultProperty value)
+ {
+ for(int i = 0; i < _count; i++)
+ {
+
if(_innerList[i].PropertyName==value.PropertyName)
+ {
+ RemoveAt(i);
+ return;
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Removes a ResultProperty at the given index. The size of
the list is
+ /// decreased by one.
+ /// </summary>
+ /// <param name="index"></param>
+ public void RemoveAt(int index)
+ {
+ if (index < 0 || index >= _count)
+ {
+ throw new ArgumentOutOfRangeException("index");
+ }
+
+ int remaining = _count - index - 1;
+
+ if (remaining > 0)
+ {
+ Array.Copy(_innerList, index + 1, _innerList,
index, remaining);
+ }
+
+ _count--;
+ _innerList[_count] = null;
+ }
+
+ /// <summary>
+ /// Ensures that the capacity of this collection is at least
the given minimum
+ /// value. If the currect capacity of the list is less than
min, the
+ /// capacity is increased to twice the current capacity.
+ /// </summary>
+ /// <param name="minSize"></param>
+ private void Resize(int minSize)
+ {
+ int oldSize = _innerList.Length;
+
+ if (minSize > oldSize)
+ {
+ ResultProperty[] oldEntries = _innerList;
+ int newSize = oldEntries.Length *
_capacityMultiplier;
+
+ if (newSize < minSize)
+ {
+ newSize = minSize;
+ }
+ _innerList = new ResultProperty[newSize];
+ Array.Copy(oldEntries, 0, _innerList, 0,
_count);
+ }
+ }
+ }
+}
Propchange:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?rev=393376&r1=393375&r2=393376&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Tue
Apr 11 21:21:03 2006
@@ -283,6 +283,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath =
"Configuration\ResultMapping\ResultPropertyCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Configuration\ResultMapping\SubMap.cs"
SubType = "Code"
BuildAction = "Compile"
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=393376&r1=393375&r2=393376&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Tue Apr 11 21:21:03 2006
@@ -224,10 +224,11 @@
bool dataFound = false;
// For each Property in the ResultMap, set the property
in the object
- foreach(DictionaryEntry entry in
resultMap.ColumnsToPropertiesMap)
+ for(int index=0; index< resultMap.Properties.Count;
index++)
+
{
request.IsRowDataFound = false;
- ResultProperty property =
(ResultProperty)entry.Value;
+ ResultProperty property =
resultMap.Properties[index];
SetObjectProperty(request, resultMap, property,
ref resultObject, reader);
dataFound = dataFound || request.IsRowDataFound;
}
@@ -258,9 +259,9 @@
}
// For each Property in the ResultMap, set the
property in the object
- foreach(DictionaryEntry entry in
resultMap.ColumnsToPropertiesMap)
+ for(int index=0; index<
resultMap.Properties.Count; index++)
{
- ResultProperty property =
(ResultProperty)entry.Value;
+ ResultProperty property =
resultMap.Properties[index];
SetObjectProperty(request, resultMap,
property, ref outObject, reader);
}
}
@@ -1532,9 +1533,10 @@
/// <param name="resultObject"></param>
public void AutoMapReader(IDataReader reader, ref
object resultObject)
{
- foreach (string key in
_resultMap.ColumnsToPropertiesMap.Keys)
+ for(int index=0; index<
_resultMap.Properties.Count; index++)
+
{
- ResultProperty property =
(ResultProperty) _resultMap.ColumnsToPropertiesMap[key];
+ ResultProperty property =
_resultMap.Properties[index];
_resultMap.SetValueOfProperty( ref
resultObject, property,
property.GetDataBaseValue(
reader ));
}