From: <dav...@us...> - 2008-11-26 22:38:54
|
Revision: 3934 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3934&view=rev Author: davybrion Date: 2008-11-26 22:38:49 +0000 (Wed, 26 Nov 2008) Log Message: ----------- various minor cleanups Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs trunk/nhibernate/src/NHibernate/Collection/PersistentArrayHolder.cs trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs trunk/nhibernate/src/NHibernate/Collection/PersistentList.cs trunk/nhibernate/src/NHibernate/Collection/PersistentMap.cs trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs trunk/nhibernate/src/NHibernate/Criterion/InExpression.cs trunk/nhibernate/src/NHibernate/Criterion/Junction.cs trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs trunk/nhibernate/src/NHibernate/Driver/NDataReader.cs trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs trunk/nhibernate/src/NHibernate/Hql/Classic/PathExpressionParser.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -24,8 +24,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } IPersistentCollection collection = Collection; Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -61,8 +61,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } PreRemove(); Modified: trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -34,8 +34,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } PreUpdate(); Modified: trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -39,8 +39,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } bool veto = PreDelete(); Modified: trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -62,8 +62,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } bool veto = PreInsert(); Modified: trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -46,8 +46,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } bool veto = PreInsert(); Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -51,8 +51,7 @@ Stopwatch stopwatch = null; if (statsEnabled) { - stopwatch = new Stopwatch(); - stopwatch.Start(); + stopwatch = Stopwatch.StartNew(); } bool veto = PreUpdate(); Modified: trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -16,7 +16,7 @@ private int countOfCommands = 0; private int totalExpectedRowsAffected; private IDbCommand currentBatch; - private IDictionary<string, ArrayList> parameterValueArrayHashTable; + private IDictionary<string, List<object>> parameterValueListHashTable; private IDictionary<string, bool> parameterIsAllNullsHashTable; @@ -37,7 +37,7 @@ { // use first command as the batching command currentBatch = CurrentCommand; - parameterValueArrayHashTable = new Dictionary<string, ArrayList>(); + parameterValueListHashTable = new Dictionary<string, List<object>>(); //oracle does not allow array containing all null values // so this Dictionary is keeping track if all values are null or not parameterIsAllNullsHashTable = new Dictionary<string, bool>(); @@ -47,25 +47,25 @@ firstOnBatch = false; } - ArrayList parameterValueArray; + List<object> parameterValueList; foreach (IDataParameter currentParameter in CurrentCommand.Parameters) { if (firstOnBatch) { - parameterValueArray = new ArrayList(); - parameterValueArrayHashTable.Add(currentParameter.ParameterName, parameterValueArray); + parameterValueList = new List<object>(); + parameterValueListHashTable.Add(currentParameter.ParameterName, parameterValueList); parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true); } else { - parameterValueArray = parameterValueArrayHashTable[currentParameter.ParameterName]; + parameterValueList = parameterValueListHashTable[currentParameter.ParameterName]; } if (currentParameter.Value != DBNull.Value) { parameterIsAllNullsHashTable[currentParameter.ParameterName] = false; } - parameterValueArray.Add(currentParameter.Value); + parameterValueList.Add(currentParameter.Value); } countOfCommands++; @@ -89,7 +89,7 @@ foreach (IDataParameter currentParameter in currentBatch.Parameters) { - ArrayList parameterValueArray = parameterValueArrayHashTable[currentParameter.ParameterName]; + List<object> parameterValueArray = parameterValueListHashTable[currentParameter.ParameterName]; currentParameter.Value = parameterValueArray.ToArray(); arraySize = parameterValueArray.Count; } @@ -104,7 +104,7 @@ totalExpectedRowsAffected = 0; currentBatch = null; - parameterValueArrayHashTable = null; + parameterValueListHashTable = null; } } Modified: trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -65,31 +65,29 @@ { return false; } - else + + long ts = session.Timestamp; + + if (log.IsDebugEnabled) { - long ts = session.Timestamp; + log.Debug("caching query results in region: " + regionName); + } - if (log.IsDebugEnabled) + IList cacheable = new List<object>(result.Count + 1); + cacheable.Add(ts); + for (int i = 0; i < result.Count; i++) + { + if (returnTypes.Length == 1) { - log.Debug("caching query results in region: " + regionName); + cacheable.Add(returnTypes[0].Disassemble(result[i], session, null)); } - - IList cacheable = new ArrayList(result.Count + 1); - cacheable.Add(ts); - for (int i = 0; i < result.Count; i++) + else { - if (returnTypes.Length == 1) - { - cacheable.Add(returnTypes[0].Disassemble(result[i], session, null)); - } - else - { - cacheable.Add(TypeFactory.Disassemble((object[]) result[i], returnTypes, null, session, null)); - } + cacheable.Add(TypeFactory.Disassemble((object[]) result[i], returnTypes, null, session, null)); } - queryCache.Put(key, cacheable); - return true; } + queryCache.Put(key, cacheable); + return true; } public IList Get(QueryKey key, ICacheAssembler[] returnTypes, bool isNaturalKeyLookup, ISet<string> spaces, @@ -125,7 +123,7 @@ TypeFactory.BeforeAssemble((object[])cacheable[i], returnTypes, session); } } - IList result = new ArrayList(cacheable.Count - 1); + IList result = new List<object>(cacheable.Count - 1); for (int i = 1; i < cacheable.Count; i++) { try @@ -151,10 +149,8 @@ queryCache.Remove(key); return null; } - else - { - throw; - } + + throw; } } return result; Modified: trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -646,8 +646,8 @@ { if (HasQueuedOperations) { - ArrayList additions = new ArrayList(operationQueue.Count); - ArrayList removals = new ArrayList(operationQueue.Count); + List<object> additions = new List<object>(operationQueue.Count); + List<object> removals = new List<object>(operationQueue.Count); for (int i = 0; i < operationQueue.Count; i++) { IDelayedOperation op = operationQueue[i]; @@ -662,10 +662,8 @@ } return GetOrphans(removals, additions, entityName, session); } - else - { - return CollectionHelper.EmptyCollection; - } + + return CollectionHelper.EmptyCollection; } /// <summary> @@ -707,7 +705,7 @@ IType idType = session.Factory.GetEntityPersister(entityName).IdentifierType; // create the collection holding the orphans - ArrayList res = new ArrayList(); + List<object> res = new List<object>(); // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access HashedSet<TypedValue> currentIds = new HashedSet<TypedValue>(); @@ -740,7 +738,7 @@ IType idType = session.Factory.GetEntityPersister(entityName).IdentifierType; object idOfCurrent = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, obj, session); - ArrayList toRemove = new ArrayList(list.Count); + List<object> toRemove = new List<object>(list.Count); foreach (object current in list) { if (current == null) Modified: trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/Generic/PersistentGenericMap.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -50,7 +50,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { - IList deletes = new ArrayList(); + IList deletes = new List<object>(); IDictionary<TKey, TValue> sn = (IDictionary<TKey, TValue>)GetSnapshot(); foreach (KeyValuePair<TKey, TValue> e in sn) { Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentArrayHolder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentArrayHolder.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentArrayHolder.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Data; using System.Diagnostics; using log4net; @@ -29,7 +30,7 @@ /// A temporary list that holds the objects while the PersistentArrayHolder is being /// populated from the database. /// </summary> - [NonSerialized] private ArrayList tempList; + [NonSerialized] private List<object> tempList; public PersistentArrayHolder(ISessionImplementor session, object array) : base(session) { @@ -97,7 +98,7 @@ { object[] sn = (object[]) snapshot; object[] arr = (object[]) array; - ArrayList result = new ArrayList(sn); + List<object> result = new List<object>(sn); for (int i = 0; i < sn.Length; i++) { IdentityRemove(result, arr[i], entityName, Session); @@ -165,7 +166,7 @@ public override void BeginRead() { base.BeginRead(); - tempList = new ArrayList(); + tempList = new List<object>(); } /// <summary> @@ -223,7 +224,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { - IList deletes = new ArrayList(); + IList deletes = new List<object>(); Array sn = (Array) GetSnapshot(); int snSize = sn.Length; int arraySize = array.Length; Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Data; using System.Diagnostics; using NHibernate.DebugHelpers; @@ -134,7 +135,7 @@ public override ICollection GetSnapshot(ICollectionPersister persister) { EntityMode entityMode = Session.EntityMode; - ArrayList clonedList = new ArrayList(bag.Count); + List<object> clonedList = new List<object>(bag.Count); foreach (object current in bag) { clonedList.Add(persister.ElementType.DeepCopy(current, entityMode, persister.Factory)); @@ -210,7 +211,7 @@ { IType elementType = persister.ElementType; EntityMode entityMode = Session.EntityMode; - ArrayList deletes = new ArrayList(); + List<object> deletes = new List<object>(); IList sn = (IList) GetSnapshot(); int i = 0; foreach (object old in sn) @@ -440,7 +441,7 @@ if (persister.IsOneToMany && HasQueuedOperations) { int additionStartFrom = bag.Count; - IList additionQueue = new ArrayList(additionStartFrom); + IList additionQueue = new List<object>(additionStartFrom); foreach (object o in QueuedAdditionIterator) { if (o != null) Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -95,7 +95,7 @@ public override void BeforeInitialize(ICollectionPersister persister, int anticipatedSize) { identifiers = anticipatedSize <= 0 ? new Dictionary<int, object>() : new Dictionary<int, object>(anticipatedSize + 1); - values = anticipatedSize <= 0 ? new ArrayList() : new ArrayList(anticipatedSize); + values = anticipatedSize <= 0 ? new List<object>() : new List<object>(anticipatedSize); } public override object Disassemble(ICollectionPersister persister) Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentList.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentList.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentList.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Data; using System.Diagnostics; using NHibernate.DebugHelpers; @@ -54,7 +55,7 @@ { EntityMode entityMode = Session.EntityMode; - ArrayList clonedList = new ArrayList(list.Count); + List<object> clonedList = new List<object>(list.Count); foreach (object current in list) { object deepCopy = persister.ElementType.DeepCopy(current, entityMode, persister.Factory); @@ -164,7 +165,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { - IList deletes = new ArrayList(); + IList deletes = new List<object>(); IList sn = (IList) GetSnapshot(); int end; if (sn.Count > list.Count) Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentMap.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentMap.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentMap.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Data; using System.Diagnostics; using NHibernate.DebugHelpers; @@ -152,7 +153,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { - IList deletes = new ArrayList(); + IList deletes = new List<object>(); IDictionary sn = (IDictionary) GetSnapshot(); foreach (DictionaryEntry e in sn) { Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Data; using System.Diagnostics; using Iesi.Collections; @@ -102,15 +103,13 @@ { return false; } - else + + foreach (object obj in set) { - foreach (object obj in set) + object oldValue = snapshot[obj]; + if (oldValue == null || elementType.IsDirty(oldValue, obj, Session)) { - object oldValue = snapshot[obj]; - if (oldValue == null || elementType.IsDirty(oldValue, obj, Session)) - { - return false; - } + return false; } } @@ -177,7 +176,7 @@ public override void BeginRead() { base.BeginRead(); - tempList = new ArrayList(); + tempList = new List<object>(); } /// <summary> @@ -214,7 +213,7 @@ { IType elementType = persister.ElementType; IDictionary sn = (IDictionary) GetSnapshot(); - ArrayList deletes = new ArrayList(sn.Count); + List<object> deletes = new List<object>(sn.Count); foreach (object obj in sn.Keys) { if (!set.Contains(obj)) Modified: trunk/nhibernate/src/NHibernate/Criterion/InExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/InExpression.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Criterion/InExpression.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -115,7 +115,7 @@ public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery) { - ArrayList list = new ArrayList(); + List<TypedValue> list = new List<TypedValue>(); IType type; if (_projection == null) { @@ -158,7 +158,7 @@ } } - return (TypedValue[]) list.ToArray(typeof (TypedValue)); + return list.ToArray(); } public object[] Values Modified: trunk/nhibernate/src/NHibernate/Criterion/Junction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Junction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Criterion/Junction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -14,7 +14,7 @@ [Serializable] public abstract class Junction : AbstractCriterion { - private IList _criteria = new ArrayList(); + private readonly IList<ICriterion> criteria = new List<ICriterion>(); /// <summary> /// Adds an <see cref="ICriterion"/> to the list of <see cref="ICriterion"/>s @@ -26,7 +26,7 @@ /// </returns> public Junction Add(ICriterion criterion) { - _criteria.Add(criterion); + criteria.Add(criterion); return this; } @@ -39,7 +39,7 @@ { ArrayList typedValues = new ArrayList(); - foreach (ICriterion criterion in _criteria) + foreach (ICriterion criterion in this.criteria) { TypedValue[] subvalues = criterion.GetTypedValues(criteria, criteriaQuery); ArrayHelper.AddAll(typedValues, subvalues); @@ -56,7 +56,7 @@ public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters) { - if (_criteria.Count == 0) + if (this.criteria.Count == 0) { return EmptyExpression; } @@ -66,15 +66,13 @@ sqlBuilder.Add("("); - for (int i = 0; i < _criteria.Count - 1; i++) + for (int i = 0; i < this.criteria.Count - 1; i++) { - sqlBuilder.Add( - ((ICriterion) _criteria[i]).ToSqlString(criteria, criteriaQuery, enabledFilters)); + sqlBuilder.Add(this.criteria[i].ToSqlString(criteria, criteriaQuery, enabledFilters)); sqlBuilder.Add(Op); } - sqlBuilder.Add( - ((ICriterion) _criteria[_criteria.Count - 1]).ToSqlString(criteria, criteriaQuery, enabledFilters)); + sqlBuilder.Add(this.criteria[this.criteria.Count - 1].ToSqlString(criteria, criteriaQuery, enabledFilters)); sqlBuilder.Add(")"); @@ -84,7 +82,7 @@ public override string ToString() { - return '(' + StringHelper.Join(Op, _criteria) + ')'; + return '(' + StringHelper.Join(Op, criteria) + ')'; } public override IProjection[] GetProjections() Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,7 @@ using System; using System.Collections; +using System.Collections.Generic; + using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.Type; @@ -95,101 +97,96 @@ // so we trim leading and trailing spaces return BothSpaceTrim.Render(args, factory); } - else if (StringHelper.EqualsCaseInsensitive("from", firstArg)) + + if (StringHelper.EqualsCaseInsensitive("from", firstArg)) { // we have the form: trim(from trimSource). // This is functionally equivalent to trim(trimSource) return BothSpaceTrimFrom.Render(args, factory); } + + // otherwise, a trim-specification and/or a trim-character + // have been specified; we need to decide which options + // are present and "do the right thing" + bool leading = true; // should leading trim-characters be trimmed? + bool trailing = true; // should trailing trim-characters be trimmed? + string trimCharacter = null; // the trim-character + object trimSource = null; // the trim-source + + // potentialTrimCharacterArgIndex = 1 assumes that a + // trim-specification has been specified. we handle the + // exception to that explicitly + int potentialTrimCharacterArgIndex = 1; + if (StringHelper.EqualsCaseInsensitive("leading", firstArg)) + { + trailing = false; + } + else if (StringHelper.EqualsCaseInsensitive("trailing", firstArg)) + { + leading = false; + } + else if (StringHelper.EqualsCaseInsensitive("both", firstArg)) + { + } else { - // otherwise, a trim-specification and/or a trim-character - // have been specified; we need to decide which options - // are present and "do the right thing" - bool leading = true; // should leading trim-characters be trimmed? - bool trailing = true; // should trailing trim-characters be trimmed? - string trimCharacter = null; // the trim-character - object trimSource = null; // the trim-source + potentialTrimCharacterArgIndex = 0; + } - // potentialTrimCharacterArgIndex = 1 assumes that a - // trim-specification has been specified. we handle the - // exception to that explicitly - int potentialTrimCharacterArgIndex = 1; - if (StringHelper.EqualsCaseInsensitive("leading", firstArg)) + object potentialTrimCharacter = args[potentialTrimCharacterArgIndex]; + if (StringHelper.EqualsCaseInsensitive("from", potentialTrimCharacter.ToString())) + { + trimCharacter = "' '"; + trimSource = args[potentialTrimCharacterArgIndex + 1]; + } + else if (potentialTrimCharacterArgIndex + 1 >= args.Count) + { + trimCharacter = "' '"; + trimSource = potentialTrimCharacter; + } + else + { + trimCharacter = potentialTrimCharacter.ToString(); + if (StringHelper.EqualsCaseInsensitive("from", args[potentialTrimCharacterArgIndex + 1].ToString())) { - trailing = false; + trimSource = args[potentialTrimCharacterArgIndex + 2]; } - else if (StringHelper.EqualsCaseInsensitive("trailing", firstArg)) - { - leading = false; - } - else if (StringHelper.EqualsCaseInsensitive("both", firstArg)) - { - } else { - potentialTrimCharacterArgIndex = 0; - } - - object potentialTrimCharacter = args[potentialTrimCharacterArgIndex]; - if (StringHelper.EqualsCaseInsensitive("from", potentialTrimCharacter.ToString())) - { - trimCharacter = "' '"; trimSource = args[potentialTrimCharacterArgIndex + 1]; } - else if (potentialTrimCharacterArgIndex + 1 >= args.Count) - { - trimCharacter = "' '"; - trimSource = potentialTrimCharacter; - } - else - { - trimCharacter = potentialTrimCharacter.ToString(); - if (StringHelper.EqualsCaseInsensitive("from", args[potentialTrimCharacterArgIndex + 1].ToString())) - { - trimSource = args[potentialTrimCharacterArgIndex + 2]; - } - else - { - trimSource = args[potentialTrimCharacterArgIndex + 1]; - } - } + } - IList argsToUse = new ArrayList(); - argsToUse.Add(trimSource); - argsToUse.Add(trimCharacter); + IList argsToUse = new List<object>(); + argsToUse.Add(trimSource); + argsToUse.Add(trimCharacter); - if (trimCharacter.Equals("' '")) + if (trimCharacter.Equals("' '")) + { + if (leading && trailing) { - if (leading && trailing) - { - return BothSpaceTrim.Render(argsToUse, factory); - } - else if (leading) - { - return LeadingSpaceTrim.Render(argsToUse, factory); - } - else - { - return TrailingSpaceTrim.Render(argsToUse, factory); - } + return BothSpaceTrim.Render(argsToUse, factory); } - else + + if (leading) { - if (leading && trailing) - { - return BothTrim.Render(argsToUse, factory); - } - else if (leading) - { - return LeadingTrim.Render(argsToUse, factory); - } - else - { - return TrailingTrim.Render(argsToUse, factory); - } + return LeadingSpaceTrim.Render(argsToUse, factory); } + + return TrailingSpaceTrim.Render(argsToUse, factory); } + + if (leading && trailing) + { + return BothTrim.Render(argsToUse, factory); + } + + if (leading) + { + return LeadingTrim.Render(argsToUse, factory); + } + + return TrailingTrim.Render(argsToUse, factory); } #endregion Modified: trunk/nhibernate/src/NHibernate/Driver/NDataReader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/NDataReader.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Driver/NDataReader.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -501,7 +501,7 @@ { schemaTable = reader.GetSchemaTable(); - ArrayList recordsList = new ArrayList(); + List<object[]> recordsList = new List<object[]>(); int rowIndex = 0; // if we are in the middle of processing the reader then don't bother @@ -533,7 +533,7 @@ isMidstream = false; } - records = (object[][]) recordsList.ToArray(typeof(object[])); + records = recordsList.ToArray(); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -12,7 +12,7 @@ public class JoinSequence { private readonly ISessionFactoryImplementor factory; - private readonly ArrayList joins = new ArrayList(); + private readonly List<Join> joins = new List<Join>(); private bool useThetaStyle = false; private readonly SqlStringBuilder conditions = new SqlStringBuilder(); private string rootAlias; @@ -162,7 +162,7 @@ for (int i = 0; i < joins.Count; i++) { - Join join = (Join) joins[i]; + Join join = joins[i]; string on = join.AssociationType.GetOnCondition(join.Alias, factory, enabledFilters); string condition; if (last != null && Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -218,7 +218,7 @@ queryParametersToUse = queryParameters; } - IList combinedResults = results ?? new ArrayList(); + IList combinedResults = results ?? new List<object>(); IdentitySet distinction = new IdentitySet(); int includedCount = -1; for (int i = 0; i < translators.Length; i++) Modified: trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Engine/Query/NativeSQLQueryPlan.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -177,7 +177,7 @@ private SqlType[] GetParameterTypes(QueryParameters parameters, ISessionImplementor session) { - ArrayList paramTypeList = new ArrayList(); + List<IType> paramTypeList = new List<IType>(); int span = 0; foreach (IType type in parameters.FilteredPositionalParameterTypes) @@ -207,7 +207,7 @@ return ConvertITypesToSqlTypes(paramTypeList, span, session); } - private static SqlType[] ConvertITypesToSqlTypes(ArrayList nhTypes, int totalSpan, ISessionImplementor session) + private static SqlType[] ConvertITypesToSqlTypes(IList<IType> nhTypes, int totalSpan, ISessionImplementor session) { SqlType[] result = new SqlType[totalSpan]; Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -292,8 +292,8 @@ SqlStringBuilder result = new SqlStringBuilder(); - IList parameters = new ArrayList(); - IList parameterTypes = new ArrayList(); + List<object> parameters = new List<object>(); + List<IType> parameterTypes = new List<IType>(); int parameterCount = 0; // keep track of the positional parameter foreach (object part in sql.Parts) @@ -367,8 +367,8 @@ } } - processedPositionalParameterValues = ((ArrayList)parameters).ToArray(); - processedPositionalParameterTypes = (IType[])((ArrayList)parameterTypes).ToArray(typeof(IType)); + processedPositionalParameterValues = parameters.ToArray(); + processedPositionalParameterTypes = parameterTypes.ToArray(); processedSQL = result.ToSqlString(); } } Modified: trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,4 +1,6 @@ using System.Collections; +using System.Collections.Generic; + using NHibernate.Engine.Query.Sql; namespace NHibernate.Engine @@ -6,7 +8,7 @@ public class ResultSetMappingDefinition { private readonly string name; - private readonly IList queryReturns = new ArrayList(); + private readonly IList<INativeSQLQueryReturn> queryReturns = new List<INativeSQLQueryReturn>(); public ResultSetMappingDefinition(string name) { Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/PathExpressionParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/PathExpressionParser.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/PathExpressionParser.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -469,12 +469,12 @@ } private bool expectingCollectionIndex; - private ArrayList collectionElements = new ArrayList(); + private readonly List<CollectionElement> collectionElements = new List<CollectionElement>(); /// <summary></summary> public CollectionElement LastCollectionElement() { - CollectionElement ce = (CollectionElement) collectionElements[collectionElements.Count - 1]; + CollectionElement ce = collectionElements[collectionElements.Count - 1]; collectionElements.RemoveAt(collectionElements.Count - 1); return ce; //remove last } @@ -482,7 +482,7 @@ /// <summary></summary> public void SetLastCollectionElementIndexValue(SqlString value) { - ((CollectionElement) collectionElements[collectionElements.Count - 1]).IndexValue.Add(value); //getlast + collectionElements[collectionElements.Count - 1].IndexValue.Add(value); //getlast } /// <summary></summary> @@ -569,11 +569,9 @@ { return AddFromCollection(q); } - else - { - q.AddFrom(currentName, joinSequence); - return currentName; - } + + q.AddFrom(currentName, joinSequence); + return currentName; } /// <summary> @@ -615,12 +613,10 @@ currentPropertyMapping = new CollectionPropertyMapping(collectionPersister); return elementName; } - else - { - // collection of values - q.AddFromCollection(collectionName, collectionRole, joinSequence); - return collectionName; - } + + // collection of values + q.AddFromCollection(collectionName, collectionRole, joinSequence); + return collectionName; } /// <summary></summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1072,7 +1072,7 @@ ExtractFunctionClause(tokens, ref tokenIdx); // The function render simply translate its name for a specific dialect. - return func.Render(new ArrayList(), Factory); + return func.Render(new List<object>(), Factory); } functionTokens = ExtractFunctionClause(tokens, ref tokenIdx); @@ -1080,7 +1080,7 @@ if (fg == null) fg = new CommonGrammar(); - IList args = new ArrayList(); + IList args = new List<object>(); SqlStringBuilder argBuf = new SqlStringBuilder(); // Extract args splitting first 2 token because are: FuncName( // last token is ')' Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -95,7 +95,7 @@ ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters, session.EntityMode); ISet<string> querySpaces = new HashedSet<string>(); - ArrayList resultTypesList = new ArrayList(); + List<IType[]> resultTypesList = new List<IType[]>(); int[] maxRows = new int[loaders.Count]; int[] firstRows = new int[loaders.Count]; for (int i = 0; i < loaders.Count; i++) @@ -159,7 +159,7 @@ private IList DoList() { - ArrayList results = new ArrayList(); + List<IList> results = new List<IList>(); GetResultsFromDatabase(results); return results; } Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -255,7 +255,7 @@ bool returnProxies) { int entitySpan = EntityPersisters.Length; - IList hydratedObjects = entitySpan == 0 ? null : new ArrayList(entitySpan); + IList hydratedObjects = entitySpan == 0 ? null : new List<object>(entitySpan); object result; try @@ -391,7 +391,7 @@ int entitySpan = EntityPersisters.Length; - ArrayList hydratedObjects = entitySpan == 0 ? null : new ArrayList(entitySpan * 10); + List<object> hydratedObjects = entitySpan == 0 ? null : new List<object>(entitySpan * 10); IDbCommand st = PrepareQueryCommand(queryParameters, false, session); @@ -408,7 +408,7 @@ bool createSubselects = IsSubselectLoadingEnabled; List<EntityKey[]> subselectResultKeys = createSubselects ? new List<EntityKey[]>() : null; - IList results = new ArrayList(); + IList results = new List<object>(); try { @@ -1764,7 +1764,7 @@ return new SqlCommandInfo(sqlString, GetParameterTypes(parameters, useLimit, useOffset)); } - protected SqlType[] ConvertITypesToSqlTypes(ArrayList nhTypes, int totalSpan) + protected SqlType[] ConvertITypesToSqlTypes(List<IType> nhTypes, int totalSpan) { SqlType[] result = new SqlType[totalSpan]; @@ -1782,7 +1782,7 @@ /// <returns><see cref="IList" /> of <see cref="IType" /></returns> protected SqlType[] GetParameterTypes(QueryParameters parameters, bool addLimit, bool addOffset) { - ArrayList paramTypeList = new ArrayList(); + List<IType> paramTypeList = new List<IType>(); int span = 0; foreach (IType type in parameters.FilteredPositionalParameterTypes) Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs 2008-11-26 13:50:31 UTC (rev 3933) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs 2008-11-26 22:38:49 UTC (rev 3934) @@ -1,5 +1,7 @@ using System; using System.Collections; +using System.Collections.Generic; + using NHibernate.Util; namespace NHibernate.SqlCommand @@ -30,7 +32,7 @@ public class SqlStringBuilder : ISqlStringBuilder { // this holds the strings and parameters that make up the full sql statement. - private ArrayList sqlParts; + private List<object> sqlParts; private AddingSqlStringVisitor addingVisitor; @@ -59,7 +61,7 @@ /// <param name="partsCapacity">The number of parts expected.</param> public SqlStringBuilder(int partsCapacity) { - sqlParts = new ArrayList(partsCapacity); + sqlParts = new List<object>(partsCapacity); } /// <summary> @@ -68,7 +70,7 @@ /// <param name="sqlString">The SqlString to modify.</param> public SqlStringBuilder(SqlString sqlString) { - sqlParts = new ArrayList(sqlString.Count); + sqlParts = new List<object>(sqlString.Count); Add(sqlString); } @@ -311,7 +313,7 @@ /// <returns>The SqlString that was built.</returns> public SqlString ToSqlString() { - return new SqlString((object[]) sqlParts.ToArray(typeof(object))); + return new SqlString(sqlParts.ToArray()); } public override string ToString() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |