///
- private IList _advisors = new ArrayList();
+ private List _advisors = new List();
///
/// Array updated on changes to the advisors list, which is easier to
@@ -76,7 +76,7 @@ namespace Spring.Aop.Framework
///
/// List of introductions.
///
- private ArrayList _introductions = new ArrayList();
+ private List _introductions = new List();
///
/// Interface map specifying which object should interface methods be
@@ -88,7 +88,7 @@ namespace Spring.Aop.Framework
/// to the target object.
///
///
- private readonly IDictionary interfaceMap = new ListDictionary();
+ private readonly Dictionary interfaceMap = new Dictionary();
///
/// The for this instance.
@@ -108,7 +108,7 @@ namespace Spring.Aop.Framework
///
/// The list of event listeners.
///
- private readonly IList listeners = new ArrayList();
+ private readonly IList listeners = new List();
///
/// The advisor chain factory.
@@ -274,7 +274,7 @@ namespace Spring.Aop.Framework
for (int i = 0; i < this._introductions.Count; i++)
{
- IIntroductionAdvisor advisor = (IIntroductionAdvisor) this._introductions[i];
+ IIntroductionAdvisor advisor = this._introductions[i];
canBeSerialized = advisor.GetType().IsSerializable
&& advisor.Advice.GetType().IsSerializable;
if (!canBeSerialized) return false;
@@ -425,7 +425,7 @@ namespace Spring.Aop.Framework
{
lock (this.SyncRoot)
{
- return (IIntroductionAdvisor[])this._introductions.ToArray(typeof(IIntroductionAdvisor));
+ return this._introductions.ToArray();
}
}
}
@@ -680,7 +680,7 @@ namespace Spring.Aop.Framework
"Introduction index " + index + " is out of bounds: Only have " + _introductions.Count +
" introductions.");
}
- IIntroductionAdvisor advisor = (IIntroductionAdvisor)_introductions[index];
+ IIntroductionAdvisor advisor = _introductions[index];
// remove all interfaces introduced by the advisor...
foreach (Type intf in advisor.Interfaces)
{
@@ -830,8 +830,7 @@ namespace Spring.Aop.Framework
int pos = this._introductions.Count;
for (int i = 0; i < pos; i++)
{
- IIntroductionAdvisor introduction
- = (IIntroductionAdvisor)this._introductions[i];
+ IIntroductionAdvisor introduction = this._introductions[i];
if (introduction.Advice.GetType() == introductionType)
{
pos = i;
@@ -1123,7 +1122,7 @@ namespace Spring.Aop.Framework
DieIfFrozen("Cannot remove interface: configuration is frozen.");
lock (this.SyncRoot)
{
- if (intf != null && this.interfaceMap.Contains(intf))
+ if (intf != null && this.interfaceMap.ContainsKey(intf))
{
this.interfaceMap.Remove(intf);
InterfacesChanged();
@@ -1188,7 +1187,7 @@ namespace Spring.Aop.Framework
{
for (int i = 0; i < this._advisors.Count; ++i)
{
- IAdvisor advisor = (IAdvisor)this._advisors[i];
+ IAdvisor advisor = this._advisors[i];
if (advisor.Advice == advice)
{
return i;
@@ -1492,7 +1491,7 @@ namespace Spring.Aop.Framework
///
protected internal virtual void CopyConfigurationFrom(AdvisedSupport other)
{
- CopyConfigurationFrom(other, other.TargetSource, new ArrayList(other.Advisors), new ArrayList(other.Introductions));
+ CopyConfigurationFrom(other, other.TargetSource, new List(other.Advisors), new List(other.Introductions));
}
///
@@ -1515,7 +1514,7 @@ namespace Spring.Aop.Framework
/// the new target source
/// the advisors for the chain
/// the introductions for the chain
- protected internal virtual void CopyConfigurationFrom(AdvisedSupport other, ITargetSource targetSource, IList advisors, IList introductions)
+ protected internal virtual void CopyConfigurationFrom(AdvisedSupport other, ITargetSource targetSource, IList advisors, IList introductions)
{
CopyFrom(other);
this.AdvisorChainFactory = other.advisorChainFactory;
@@ -1527,13 +1526,13 @@ namespace Spring.Aop.Framework
{
this.interfaceMap[intf] = other.interfaceMap[intf];
}
- this._advisors = new ArrayList();
+ this._advisors = new List();
foreach (IAdvisor advisor in advisors)
{
AssertUtils.ArgumentNotNull(advisor, "Advisor must not be null");
AddAdvisor(advisor);
}
- this._introductions = new ArrayList();
+ this._introductions = new List();
foreach (IIntroductionAdvisor advisor in introductions)
{
// TODO (EE): implement
@@ -1575,7 +1574,7 @@ namespace Spring.Aop.Framework
foreach (Type intf in this.interfaceMap.Keys)
{
buffer.Append(separator).Append("[").Append(intf.FullName).Append("] -> ");
- IIntroductionAdvisor advisor = this.interfaceMap[intf] as IIntroductionAdvisor;
+ IIntroductionAdvisor advisor = this.interfaceMap[intf];
if (advisor == null)
{
if (TargetSource.TargetType != null)
diff --git a/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs b/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs
index f9201428..935898d8 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs
@@ -21,9 +21,11 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
+
using AopAlliance.Intercept;
+
using Spring.Aop.Framework.Adapter;
#endregion
@@ -62,10 +64,10 @@ namespace Spring.Aop.Framework
/// (if there's
/// a dynamic method matcher that needs evaluation at runtime).
///
- public static IList CalculateInterceptors(
+ public static IList
/// the advisor list
/// the object name of the advisor to add
- private void AddAdvisorCandidate(ArrayList advisors, string advisorName)
+ private void AddAdvisorCandidate(List advisors, string advisorName)
{
object advisorCandidate = _objectFactory.GetObject(advisorName);
if (advisorCandidate is IAdvisor)
{
- advisors.Add(advisorCandidate);
+ advisors.Add((IAdvisor) advisorCandidate);
}
else if (advisorCandidate is IAdvisors)
{
@@ -143,12 +145,12 @@ namespace Spring.Aop.Framework.AutoProxy
{
if (_cachedObjectNames == null)
{
- ArrayList candidateNameList = new ArrayList();
+ List candidateNameList = new List();
string[] advisorCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors( _objectFactory, typeof(IAdvisor), true, false);
candidateNameList.AddRange(advisorCandidateNames);
string[] advisorsCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_objectFactory, typeof(IAdvisors), true, false);
candidateNameList.AddRange(advisorsCandidateNames);
- _cachedObjectNames = (string[]) candidateNameList.ToArray(typeof(string));
+ _cachedObjectNames = candidateNameList.ToArray();
}
}
}
diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/PointcutFilteringAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/PointcutFilteringAutoProxyCreator.cs
index cfdb53f6..5d7ea845 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/PointcutFilteringAutoProxyCreator.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/PointcutFilteringAutoProxyCreator.cs
@@ -21,8 +21,7 @@
#region Imports
using System;
-using System.Collections;
-using Spring.Objects.Factory;
+
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs
index 8ff91c56..b4d0088a 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs
@@ -1,5 +1,6 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Spring.Aop.Support;
using Spring.Aop.Target;
@@ -57,14 +58,14 @@ namespace Spring.Aop.Framework.DynamicProxy
{
IAdvised innerProxy = (IAdvised)advisedSupport.TargetSource.GetTarget();
// eliminate duplicate advisors
- ArrayList thisAdvisors = new ArrayList(advisedSupport.Advisors);
+ List thisAdvisors = new List(advisedSupport.Advisors);
foreach (IAdvisor innerAdvisor in innerProxy.Advisors)
{
foreach (IAdvisor thisAdvisor in thisAdvisors)
{
if (ReferenceEquals(thisAdvisor, innerAdvisor)
|| (thisAdvisor.GetType() == typeof(DefaultPointcutAdvisor)
- && ((DefaultPointcutAdvisor)thisAdvisor).Equals(innerAdvisor)
+ && thisAdvisor.Equals(innerAdvisor)
)
)
{
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
index 30b4267b..695cba78 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Reflection;
using System.Runtime.Serialization;
@@ -47,7 +49,7 @@ namespace Spring.Aop.Framework.DynamicProxy
///
/// Optimization fields
///
- private static IList EmptyList = ArrayList.ReadOnly(new ArrayList());
+ private static IList EmptyList = new ReadOnlyCollection(new object[0]);
///
/// IAdvised delegate
@@ -214,7 +216,7 @@ namespace Spring.Aop.Framework.DynamicProxy
/// target type
/// target method
/// list of inteceptors for the specified method
- public IList GetInterceptors(Type targetType, MethodInfo method)
+ public IList GetInterceptors(Type targetType, MethodInfo method)
{
if (m_advised.Advisors.Length == 0)
{
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs
index 8a7ed927..42d3638d 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseAopProxyMethodBuilder.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
index c71f6bda..bee8ffdb 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/BaseCompositionAopProxy.cs
@@ -22,7 +22,6 @@
using System;
using System.Runtime.Serialization;
-using System.Security.Permissions;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs
index eb865cbd..6565d037 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs
@@ -120,7 +120,7 @@ namespace Spring.Aop.Framework.DynamicProxy
foreach (DictionaryEntry entry in targetMethods)
{
FieldInfo field = proxyType.GetField((string) entry.Key, BindingFlags.NonPublic | BindingFlags.Static);
- field.SetValue(proxyType, (MethodInfo) entry.Value);
+ field.SetValue(proxyType, entry.Value);
}
return proxyType;
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs
index 5f0ea1b4..e8892cfd 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs
@@ -155,7 +155,7 @@ namespace Spring.Aop.Framework.DynamicProxy
foreach (DictionaryEntry entry in targetMethods)
{
FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static);
- field.SetValue(proxyType, (MethodInfo)entry.Value);
+ field.SetValue(proxyType, entry.Value);
}
return proxyType;
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAdvisedProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAdvisedProxyMethodBuilder.cs
index 3b880216..7de3b874 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAdvisedProxyMethodBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAdvisedProxyMethodBuilder.cs
@@ -20,11 +20,8 @@
#region Imports
-using System;
-using System.Reflection;
using System.Reflection.Emit;
-using Spring.Util;
using Spring.Proxy;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAopProxyTypeGenerator.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAopProxyTypeGenerator.cs
index 8d523839..42bf076a 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAopProxyTypeGenerator.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IAopProxyTypeGenerator.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using System.Reflection.Emit;
using Spring.Proxy;
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs
index 49196a10..7368b1ad 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs
@@ -174,7 +174,7 @@ namespace Spring.Aop.Framework.DynamicProxy
foreach (DictionaryEntry entry in targetMethods)
{
FieldInfo field = proxyType.GetField((string)entry.Key, BindingFlags.NonPublic | BindingFlags.Static);
- field.SetValue(proxyType, (MethodInfo)entry.Value);
+ field.SetValue(proxyType, entry.Value);
}
// set proxy method references
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs
index ba8f51ea..3a828ddc 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/IntroductionProxyMethodBuilder.cs
@@ -20,13 +20,10 @@
#region Imports
-using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-using Spring.Util;
-
#endregion
namespace Spring.Aop.Framework.DynamicProxy
diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs
index af57e46e..25627877 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/TargetAopProxyMethodBuilder.cs
@@ -20,13 +20,10 @@
#region Imports
-using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
-using Spring.Util;
-
#endregion
namespace Spring.Aop.Framework.DynamicProxy
diff --git a/src/Spring/Spring.Aop/Aop/Framework/HashtableCachingAdvisorChainFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/HashtableCachingAdvisorChainFactory.cs
index af1b0406..6824c7cb 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/HashtableCachingAdvisorChainFactory.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/HashtableCachingAdvisorChainFactory.cs
@@ -21,10 +21,8 @@
#region Imports
using System;
-using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
using System.Reflection;
-using Spring.Collections;
#endregion
@@ -39,8 +37,8 @@ namespace Spring.Aop.Framework
[Serializable]
public sealed class HashtableCachingAdvisorChainFactory : IAdvisorChainFactory
{
- private readonly IDictionary methodCache = new ListDictionary();
-
+ private readonly IDictionary> methodCache = new Dictionary>();
+
///
/// Gets the list of and
///
@@ -59,10 +57,10 @@ namespace Spring.Aop.Framework
///
/// instances for the supplied .
///
- public IList GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType)
+ public IList GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType)
{
- IList cached = (IList)this.methodCache[method];
- if (cached == null)
+ IList cached;
+ if (!this.methodCache.TryGetValue(method, out cached))
{
// recalculate...
cached = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType);
diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs
index adb601d8..ea62cbed 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs
@@ -24,7 +24,7 @@ using System;
using System.Collections;
using AopAlliance.Aop;
-using Spring.Aop;
+
using Spring.Proxy;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAdvisedSupportListener.cs b/src/Spring/Spring.Aop/Aop/Framework/IAdvisedSupportListener.cs
index ae9be3d1..8ad1ee2e 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/IAdvisedSupportListener.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/IAdvisedSupportListener.cs
@@ -18,8 +18,6 @@
#endregion
-using System;
-
namespace Spring.Aop.Framework
{
///
diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAdvisorChainFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/IAdvisorChainFactory.cs
index 22d53a81..166603f1 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/IAdvisorChainFactory.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/IAdvisorChainFactory.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
#endregion
@@ -35,25 +35,24 @@ namespace Spring.Aop.Framework
/// Aleksandar Seovic (.NET)
public interface IAdvisorChainFactory : IAdvisedSupportListener
{
- ///
- /// Gets the list of and
- ///
- /// instances for the supplied .
- ///
- /// The proxy configuration object.
- /// The object proxy.
- ///
- /// The method for which the interceptors are to be evaluated.
- ///
- ///
- /// The of the target object.
- ///
- ///
- /// The list of and
- ///
- /// instances for the supplied .
- ///
- IList GetInterceptors(
- IAdvised advised, object proxy, MethodInfo method, Type targetType);
+ ///
+ /// Gets the list of and
+ ///
+ /// instances for the supplied .
+ ///
+ /// The proxy configuration object.
+ /// The object proxy.
+ ///
+ /// The method for which the interceptors are to be evaluated.
+ ///
+ ///
+ /// The of the target object.
+ ///
+ ///
+ /// The list of and
+ ///
+ /// instances for the supplied .
+ ///
+ IList GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAopProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/IAopProxy.cs
index 84718074..a50830c4 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/IAopProxy.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/IAopProxy.cs
@@ -20,8 +20,6 @@
#region Imports
-using System;
-
using Spring.Proxy;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/IAopProxyFactory.cs
index d33f3cbc..4e46be92 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/IAopProxyFactory.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/IAopProxyFactory.cs
@@ -18,8 +18,6 @@
#endregion
-using System;
-
namespace Spring.Aop.Framework
{
///
diff --git a/src/Spring/Spring.Aop/Aop/Framework/ITargetAware.cs b/src/Spring/Spring.Aop/Aop/Framework/ITargetAware.cs
index da6d57fd..155913b7 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/ITargetAware.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/ITargetAware.cs
@@ -18,8 +18,6 @@
#endregion
-using System;
-
namespace Spring.Aop.Framework
{
///
diff --git a/src/Spring/Spring.Aop/Aop/Framework/InterceptorAndDynamicMethodMatcher.cs b/src/Spring/Spring.Aop/Aop/Framework/InterceptorAndDynamicMethodMatcher.cs
index 8ee81040..7f2f8410 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/InterceptorAndDynamicMethodMatcher.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/InterceptorAndDynamicMethodMatcher.cs
@@ -19,8 +19,8 @@
#endregion
using System;
+
using AopAlliance.Intercept;
-using Spring.Aop;
namespace Spring.Aop.Framework
{
diff --git a/src/Spring/Spring.Aop/Aop/Framework/ProxyConfig.cs b/src/Spring/Spring.Aop/Aop/Framework/ProxyConfig.cs
index bfceeadd..e380aaad 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/ProxyConfig.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/ProxyConfig.cs
@@ -22,9 +22,7 @@
using System;
using System.Text;
-using System.Reflection;
-using Spring.Aop.Framework.DynamicProxy;
-using Spring.Core.TypeResolution;
+
using Spring.Util;
using Spring.Reflection.Dynamic;
diff --git a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs
index c75ee568..2473a5e8 100644
--- a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs
+++ b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs
@@ -22,10 +22,13 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using AopAlliance.Aop;
using AopAlliance.Intercept;
+
using Common.Logging;
+
using Spring.Aop.Framework.Adapter;
using Spring.Aop.Support;
using Spring.Aop.Target;
@@ -453,8 +456,8 @@ namespace Spring.Aop.Framework
// The copy needs a fresh advisor chain, and a fresh TargetSource.
ITargetSource targetSource = FreshTargetSource();
- IList advisorChain = FreshAdvisorChain();
- IList introductionChain = FreshIntroductionChain();
+ IList advisorChain = FreshAdvisorChain();
+ IList introductionChain = FreshIntroductionChain();
AdvisedSupport copy = new AdvisedSupport();
copy.CopyConfigurationFrom(this, targetSource, advisorChain, introductionChain);
@@ -628,8 +631,8 @@ namespace Spring.Aop.Framework
ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvisor));
string[] globalInterceptorNames =
ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IInterceptor));
- ArrayList objects = new ArrayList();
- Hashtable names = new Hashtable();
+ List objects = new List();
+ Dictionary names = new Dictionary();
for (int i = 0; i < globalAspectNames.Length; i++)
{
@@ -672,10 +675,10 @@ namespace Spring.Aop.Framework
names[obj] = name;
}
}
- ((ArrayList)objects).Sort(new OrderComparator());
+ objects.Sort(new OrderComparator());
foreach (object obj in objects)
{
- string name = (string)names[obj];
+ string name = names[obj];
AddAdvisorOnChainCreation(obj, name);
}
}
@@ -741,7 +744,7 @@ namespace Spring.Aop.Framework
string[] globalIntroductionNames =
ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvice));
ArrayList objects = new ArrayList();
- Hashtable names = new Hashtable();
+ Dictionary names = new Dictionary();
for (int i = 0; i < globalAspectNames.Length; i++)
{
@@ -791,7 +794,7 @@ namespace Spring.Aop.Framework
objects.Sort(new OrderComparator());
foreach (object obj in objects)
{
- string name = (string)names[obj];
+ string name = names[obj];
AddIntroductionOnChainCreation(obj, name);
}
}
@@ -845,10 +848,10 @@ namespace Spring.Aop.Framework
/// We need to do this every time a new prototype instance is returned,
/// to return distinct instances of prototype interfaces and pointcuts.
///
- private IList FreshAdvisorChain()
+ private IList FreshAdvisorChain()
{
IAdvisor[] advisors = Advisors;
- ArrayList freshAdvisors = new ArrayList();
+ List freshAdvisors = new List();
foreach (IAdvisor advisor in advisors)
{
if (advisor is PrototypePlaceholder)
@@ -878,10 +881,10 @@ namespace Spring.Aop.Framework
/// We need to do this every time a new prototype instance is returned,
/// to return distinct instances of prototype interfaces and pointcuts.
///
- private IList FreshIntroductionChain()
+ private IList FreshIntroductionChain()
{
IIntroductionAdvisor[] introductions = Introductions;
- ArrayList freshIntroductions = new ArrayList();
+ List freshIntroductions = new List();
foreach (IIntroductionAdvisor introduction in introductions)
{
if (introduction is PrototypePlaceholder)
diff --git a/src/Spring/Spring.Aop/Aop/IAdvisor.cs b/src/Spring/Spring.Aop/Aop/IAdvisor.cs
index ed1841cf..40f15f88 100644
--- a/src/Spring/Spring.Aop/Aop/IAdvisor.cs
+++ b/src/Spring/Spring.Aop/Aop/IAdvisor.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using AopAlliance.Aop;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/IAdvisors.cs b/src/Spring/Spring.Aop/Aop/IAdvisors.cs
index e06efa0e..8a521a36 100644
--- a/src/Spring/Spring.Aop/Aop/IAdvisors.cs
+++ b/src/Spring/Spring.Aop/Aop/IAdvisors.cs
@@ -20,9 +20,7 @@
#region Imports
-using System;
-using System.Collections;
-using AopAlliance.Aop;
+using System.Collections.Generic;
#endregion
@@ -41,6 +39,6 @@ namespace Spring.Aop
///
/// A list of advisors.
///
- IList Advisors { get; set; }
+ IList Advisors { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Aop/Aop/IAfterReturningAdvice.cs b/src/Spring/Spring.Aop/Aop/IAfterReturningAdvice.cs
index c634c20c..1ac68e22 100644
--- a/src/Spring/Spring.Aop/Aop/IAfterReturningAdvice.cs
+++ b/src/Spring/Spring.Aop/Aop/IAfterReturningAdvice.cs
@@ -20,8 +20,8 @@
#region Imports
-using System;
using System.Reflection;
+
using AopAlliance.Aop;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/IBeforeAdvice.cs b/src/Spring/Spring.Aop/Aop/IBeforeAdvice.cs
index a865326a..b4fe55fd 100644
--- a/src/Spring/Spring.Aop/Aop/IBeforeAdvice.cs
+++ b/src/Spring/Spring.Aop/Aop/IBeforeAdvice.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using AopAlliance.Aop;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/IMethodBeforeAdvice.cs b/src/Spring/Spring.Aop/Aop/IMethodBeforeAdvice.cs
index 3057bf70..c7c0b04e 100644
--- a/src/Spring/Spring.Aop/Aop/IMethodBeforeAdvice.cs
+++ b/src/Spring/Spring.Aop/Aop/IMethodBeforeAdvice.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using System.Reflection;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/IPointcut.cs b/src/Spring/Spring.Aop/Aop/IPointcut.cs
index 346edbad..b503143e 100644
--- a/src/Spring/Spring.Aop/Aop/IPointcut.cs
+++ b/src/Spring/Spring.Aop/Aop/IPointcut.cs
@@ -18,12 +18,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace Spring.Aop
{
///
diff --git a/src/Spring/Spring.Aop/Aop/IPointcutAdvisor.cs b/src/Spring/Spring.Aop/Aop/IPointcutAdvisor.cs
index 13915f01..afc123a6 100644
--- a/src/Spring/Spring.Aop/Aop/IPointcutAdvisor.cs
+++ b/src/Spring/Spring.Aop/Aop/IPointcutAdvisor.cs
@@ -18,12 +18,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace Spring.Aop
{
///
diff --git a/src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs b/src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs
index b7db9921..22d0e406 100644
--- a/src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs
+++ b/src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using AopAlliance.Aop;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Support/AbstractRegularExpressionMethodPointcut.cs b/src/Spring/Spring.Aop/Aop/Support/AbstractRegularExpressionMethodPointcut.cs
index fc212dca..34d464a1 100644
--- a/src/Spring/Spring.Aop/Aop/Support/AbstractRegularExpressionMethodPointcut.cs
+++ b/src/Spring/Spring.Aop/Aop/Support/AbstractRegularExpressionMethodPointcut.cs
@@ -24,9 +24,9 @@ using System;
using System.Reflection;
using System.Runtime.Serialization;
using System.Security.Permissions;
+
using AopAlliance.Aop;
-using Spring.Core;
-using Spring.Objects;
+
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Support/NameMatchMethodPointcutAdvisor.cs b/src/Spring/Spring.Aop/Aop/Support/NameMatchMethodPointcutAdvisor.cs
index e965f4f1..4e56dc8f 100644
--- a/src/Spring/Spring.Aop/Aop/Support/NameMatchMethodPointcutAdvisor.cs
+++ b/src/Spring/Spring.Aop/Aop/Support/NameMatchMethodPointcutAdvisor.cs
@@ -21,8 +21,9 @@
#region Imports
using System;
+
using AopAlliance.Aop;
-using Spring.Core;
+
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Support/StaticMethodMatcherPointcut.cs b/src/Spring/Spring.Aop/Aop/Support/StaticMethodMatcherPointcut.cs
index fd6aba77..ed9743ba 100644
--- a/src/Spring/Spring.Aop/Aop/Support/StaticMethodMatcherPointcut.cs
+++ b/src/Spring/Spring.Aop/Aop/Support/StaticMethodMatcherPointcut.cs
@@ -19,7 +19,6 @@
#endregion
using System;
-using System.Reflection;
namespace Spring.Aop.Support
{
diff --git a/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs b/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs
index d03dd4fb..20a73fd5 100644
--- a/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs
+++ b/src/Spring/Spring.Aop/Aop/Target/AbstractPrototypeTargetSource.cs
@@ -21,10 +21,10 @@
#region Imports
using System;
-using System.Globalization;
+
using Common.Logging;
+
using Spring.Objects.Factory;
-using Spring.Objects.Factory.Support;
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Target/IThreadLocalTargetSourceStats.cs b/src/Spring/Spring.Aop/Aop/Target/IThreadLocalTargetSourceStats.cs
index 0a3619a4..ef4ae645 100644
--- a/src/Spring/Spring.Aop/Aop/Target/IThreadLocalTargetSourceStats.cs
+++ b/src/Spring/Spring.Aop/Aop/Target/IThreadLocalTargetSourceStats.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using AopAlliance.Intercept;
#endregion
diff --git a/src/Spring/Spring.Aop/Aop/Target/PoolingConfig.cs b/src/Spring/Spring.Aop/Aop/Target/PoolingConfig.cs
index 0e261cd3..b9c3d7b8 100644
--- a/src/Spring/Spring.Aop/Aop/Target/PoolingConfig.cs
+++ b/src/Spring/Spring.Aop/Aop/Target/PoolingConfig.cs
@@ -18,12 +18,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace Spring.Aop.Target
{
///
diff --git a/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs b/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs
index 79d2b19a..6b03f9e2 100644
--- a/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs
+++ b/src/Spring/Spring.Aop/Aop/Target/ThreadLocalTargetSource.cs
@@ -21,9 +21,10 @@
#region Imports
using System;
-using System.Globalization;
using System.Threading;
+
using AopAlliance.Intercept;
+
using Spring.Aop.Support;
using Spring.Collections;
using Spring.Util;
diff --git a/src/Spring/Spring.Aop/AopAlliance/Aop/IAdvice.cs b/src/Spring/Spring.Aop/AopAlliance/Aop/IAdvice.cs
index dd94810d..cf37d9eb 100644
--- a/src/Spring/Spring.Aop/AopAlliance/Aop/IAdvice.cs
+++ b/src/Spring/Spring.Aop/AopAlliance/Aop/IAdvice.cs
@@ -9,12 +9,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace AopAlliance.Aop
{
///
diff --git a/src/Spring/Spring.Aop/AopAlliance/Intercept/IConstructorInterceptor.cs b/src/Spring/Spring.Aop/AopAlliance/Intercept/IConstructorInterceptor.cs
index 8f39324e..47321f42 100644
--- a/src/Spring/Spring.Aop/AopAlliance/Intercept/IConstructorInterceptor.cs
+++ b/src/Spring/Spring.Aop/AopAlliance/Intercept/IConstructorInterceptor.cs
@@ -9,12 +9,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace AopAlliance.Intercept
{
///
diff --git a/src/Spring/Spring.Aop/AopAlliance/Intercept/IInterceptor.cs b/src/Spring/Spring.Aop/AopAlliance/Intercept/IInterceptor.cs
index 0689389b..70a0457a 100644
--- a/src/Spring/Spring.Aop/AopAlliance/Intercept/IInterceptor.cs
+++ b/src/Spring/Spring.Aop/AopAlliance/Intercept/IInterceptor.cs
@@ -11,7 +11,6 @@
#region Imports
-using System;
using AopAlliance.Aop;
#endregion
diff --git a/src/Spring/Spring.Aop/AopAlliance/Intercept/IInvocation.cs b/src/Spring/Spring.Aop/AopAlliance/Intercept/IInvocation.cs
index 8782ae19..5af05a06 100644
--- a/src/Spring/Spring.Aop/AopAlliance/Intercept/IInvocation.cs
+++ b/src/Spring/Spring.Aop/AopAlliance/Intercept/IInvocation.cs
@@ -9,12 +9,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace AopAlliance.Intercept
{
///
diff --git a/src/Spring/Spring.Aop/AopAlliance/Intercept/IMethodInterceptor.cs b/src/Spring/Spring.Aop/AopAlliance/Intercept/IMethodInterceptor.cs
index 0b0355ef..a253338b 100644
--- a/src/Spring/Spring.Aop/AopAlliance/Intercept/IMethodInterceptor.cs
+++ b/src/Spring/Spring.Aop/AopAlliance/Intercept/IMethodInterceptor.cs
@@ -9,12 +9,6 @@
#endregion
-#region Imports
-
-using System;
-
-#endregion
-
namespace AopAlliance.Intercept
{
///
diff --git a/src/Spring/Spring.Aop/Aspects/AbstractExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/AbstractExceptionHandler.cs
index 80d177d1..29a52edb 100644
--- a/src/Spring/Spring.Aop/Aspects/AbstractExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/AbstractExceptionHandler.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Common.Logging;
using Spring.Expressions;
@@ -128,8 +129,6 @@ namespace Spring.Aspects
#endregion
-
-
///
/// Determines whether this instance can handle the exception the specified exception.
///
@@ -138,7 +137,7 @@ namespace Spring.Aspects
///
/// true if this instance can handle the specified exception; otherwise, false.
///
- public bool CanHandleException(Exception ex, IDictionary callContextDictionary)
+ public bool CanHandleException(Exception ex, IDictionary callContextDictionary)
{
if (SourceExceptionNames != null)
{
@@ -176,7 +175,7 @@ namespace Spring.Aspects
/// Handles the exception.
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
- public abstract object HandleException(IDictionary callContextDictionary);
+ public abstract object HandleException(IDictionary callContextDictionary);
#endregion
}
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs
index cc591d2f..bd1ab35e 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/BaseCacheAdvice.cs
@@ -21,12 +21,14 @@
#region Imports
using System;
+using System.Collections.Generic;
using System.Reflection;
+
using Common.Logging;
+
using Spring.Caching;
using Spring.Context;
using Spring.Expressions;
-using System.Collections;
#endregion
@@ -104,9 +106,9 @@ namespace Spring.Aspects.Cache
///
/// A dictionary containing all method arguments, keyed by method name.
///
- protected static IDictionary PrepareVariables(MethodInfo method, object[] arguments)
+ protected static IDictionary PrepareVariables(MethodInfo method, object[] arguments)
{
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
vars[method.Name] = method;
@@ -141,7 +143,7 @@ namespace Spring.Aspects.Cache
/// If the SpEL expression could not be successfuly resolved to a boolean.
///
protected static bool EvalCondition(string condition,
- IExpression conditionExpression, object context, IDictionary variables)
+ IExpression conditionExpression, object context, IDictionary variables)
{
if (conditionExpression == null)
{
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/CacheAspect.cs b/src/Spring/Spring.Aop/Aspects/Cache/CacheAspect.cs
index 43db0ffc..eda880bf 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/CacheAspect.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/CacheAspect.cs
@@ -21,7 +21,8 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Spring.Aop;
using Spring.Context;
@@ -59,7 +60,7 @@ namespace Spring.Aspects.Cache
///
/// A list of advisors for this aspect.
///
- public IList Advisors
+ public IList Advisors
{
get { return advisors; }
set { throw new NotSupportedException("Cache aspect advisors cannot be set externally."); }
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs
index 91d624f4..e387bcdc 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/CacheParameterAdvice.cs
@@ -20,10 +20,10 @@
#region Imports
-using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
-using Common.Logging;
+
using Spring.Aop;
using Spring.Caching;
using Spring.Util;
@@ -123,7 +123,7 @@ namespace Spring.Aspects.Cache
if (cacheParameterAttributes.Length > 0)
{
- IDictionary vars = PrepareVariables(method, arguments);
+ IDictionary vars = PrepareVariables(method, arguments);
for (int i = 0; i < cacheParameterAttributes.Length; i++)
{
foreach (CacheParameterAttribute paramInfo in cacheParameterAttributes[i])
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs
index c3f2fa50..dfea8bac 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs
@@ -21,11 +21,12 @@
#region Imports
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
+
using AopAlliance.Intercept;
-using Common.Logging;
+
using Spring.Caching;
-using Spring.Expressions;
using Spring.Util;
using System;
@@ -137,7 +138,7 @@ namespace Spring.Aspects.Cache
CacheResultInfo cacheResultInfo = GetCacheResultInfo(invocation.Method);
// prepare variables for SpEL expressions
- IDictionary vars = PrepareVariables(invocation.Method, invocation.Arguments);
+ IDictionary vars = PrepareVariables(invocation.Method, invocation.Arguments);
bool cacheHit = false;
object returnValue = GetReturnValue(invocation, cacheResultInfo.ResultInfo, vars, out cacheHit);
@@ -171,7 +172,7 @@ namespace Spring.Aspects.Cache
///
/// Return value for the specified .
///
- private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, IDictionary vars, out bool cacheHit)
+ private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, IDictionary vars, out bool cacheHit)
{
if (resultInfo != null)
{
@@ -258,7 +259,7 @@ namespace Spring.Aspects.Cache
///
/// Variables for expression evaluation.
///
- private void CacheResultItems(IEnumerable items, CacheResultItemsAttribute[] itemInfoArray, IDictionary vars)
+ private void CacheResultItems(IEnumerable items, CacheResultItemsAttribute[] itemInfoArray, IDictionary vars)
{
foreach (CacheResultItemsAttribute itemInfo in itemInfoArray)
{
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs
index 4453f9dd..b66cabb7 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvice.cs
@@ -21,11 +21,11 @@
#region Imports
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Spring.Aop;
using Spring.Caching;
-using Spring.Util;
#endregion
@@ -103,7 +103,7 @@ namespace Spring.Aspects.Cache
if (cacheInfoArray.Length > 0)
{
- IDictionary vars = PrepareVariables(method, arguments);
+ IDictionary vars = PrepareVariables(method, arguments);
foreach (InvalidateCacheAttribute cacheInfo in cacheInfoArray)
{
if (EvalCondition(cacheInfo.Condition, cacheInfo.ConditionExpression, returnValue, vars))
@@ -121,7 +121,7 @@ namespace Spring.Aspects.Cache
logger.Debug(string.Format("Removing objects for keys [{0}] from cache [{1}].", keys, cacheInfo.CacheName));
}
#endregion
- cache.RemoveAll(keys as ICollection);
+ cache.RemoveAll((ICollection) keys);
}
else
{
diff --git a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvisor.cs b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvisor.cs
index fb00cfb2..1a373b73 100644
--- a/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvisor.cs
+++ b/src/Spring/Spring.Aop/Aspects/Cache/InvalidateCacheAdvisor.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using Spring.Aop.Support;
using Spring.Caching;
using Spring.Context;
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs
index c67216b2..4a34a6c3 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/ExceptionHandlerAdvice.cs
@@ -20,11 +20,13 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
+
using AopAlliance.Intercept;
+
using Common.Logging;
-using Spring.Context;
-using Spring.Objects.Factory.Config;
+
using Spring.Util;
namespace Spring.Aspects.Exceptions
@@ -287,7 +289,7 @@ namespace Spring.Aspects.Exceptions
/// The output of
protected virtual object InvokeHandlers(Exception ex, IMethodInvocation invocation)
{
- IDictionary callContextDictionary = new Hashtable();
+ Dictionary callContextDictionary = new Dictionary();
callContextDictionary.Add("method", invocation.Method);
callContextDictionary.Add("args", invocation.Arguments);
callContextDictionary.Add("target", invocation.Target);
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/ExecuteSpelExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/ExecuteSpelExceptionHandler.cs
index 4204fc64..c1bc1bfe 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/ExecuteSpelExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/ExecuteSpelExceptionHandler.cs
@@ -1,7 +1,8 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -31,7 +32,7 @@ namespace Spring.Aspects.Exceptions
/// Handles the exception.
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
try
{
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs
index e164afc7..6d196e0c 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/LogExceptionHandler.cs
@@ -19,8 +19,10 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Common.Logging;
+
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -132,7 +134,7 @@ namespace Spring.Aspects.Exceptions
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
///
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
//TODO log name is targettype.
ILog adviceLogger = LogManager.GetLogger(logName);
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/ReturnValueExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/ReturnValueExceptionHandler.cs
index a40c9779..b7bfa7b4 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/ReturnValueExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/ReturnValueExceptionHandler.cs
@@ -19,8 +19,8 @@
#endregion
using System;
-using System.Collections;
-using Common.Logging;
+using System.Collections.Generic;
+
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -53,7 +53,7 @@ namespace Spring.Aspects.Exceptions
/// Returns the result of evaluating the translation expression.
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
object returnVal = null;
try
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/SwallowExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/SwallowExceptionHandler.cs
index 8fd169d6..f1259bbf 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/SwallowExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/SwallowExceptionHandler.cs
@@ -18,7 +18,7 @@
#endregion
-using System.Collections;
+using System.Collections.Generic;
namespace Spring.Aspects.Exceptions
{
@@ -49,7 +49,7 @@ namespace Spring.Aspects.Exceptions
/// Handles the exception.
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
return "swallow";
}
diff --git a/src/Spring/Spring.Aop/Aspects/Exceptions/TranslationExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/Exceptions/TranslationExceptionHandler.cs
index 022de46a..c275f42a 100644
--- a/src/Spring/Spring.Aop/Aspects/Exceptions/TranslationExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/Exceptions/TranslationExceptionHandler.cs
@@ -19,8 +19,8 @@
#endregion
using System;
-using System.Collections;
-using Common.Logging;
+using System.Collections.Generic;
+
using Spring.Expressions;
namespace Spring.Aspects.Exceptions
@@ -52,7 +52,7 @@ namespace Spring.Aspects.Exceptions
/// Handles the exception.
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
object o = null;
try {
diff --git a/src/Spring/Spring.Aop/Aspects/IExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/IExceptionHandler.cs
index 2e80c72b..d17667c7 100644
--- a/src/Spring/Spring.Aop/Aspects/IExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/IExceptionHandler.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
namespace Spring.Aspects
{
@@ -37,7 +38,7 @@ namespace Spring.Aspects
///
/// true if this instance can handle the specified exception; otherwise, false.
///
- bool CanHandleException(Exception ex, IDictionary callContextDictionary);
+ bool CanHandleException(Exception ex, IDictionary callContextDictionary);
///
/// Handles the exception.
@@ -46,7 +47,7 @@ namespace Spring.Aspects
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
///
- object HandleException(IDictionary callContextDictionary);
+ object HandleException(IDictionary callContextDictionary);
///
/// Gets the source exception names.
diff --git a/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs b/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs
index d36a7183..f5329377 100644
--- a/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs
+++ b/src/Spring/Spring.Aop/Aspects/RetryAdvice.cs
@@ -16,15 +16,18 @@
* limitations under the License.
*/
-#endregion
-
-using System;
-using System.Collections;
-using System.Text.RegularExpressions;
-using System.Threading;
-using AopAlliance.Intercept;
-using Common.Logging;
-using Spring.Core.TypeConversion;
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+using AopAlliance.Intercept;
+
+using Common.Logging;
+
+using Spring.Core.TypeConversion;
using Spring.Expressions;
namespace Spring.Aspects
@@ -149,7 +152,7 @@ namespace Spring.Aspects
///
public override object Invoke(IMethodInvocation invocation)
{
- IDictionary callContextDictionary = new Hashtable();
+ IDictionary callContextDictionary = new Dictionary();
callContextDictionary.Add("method", invocation.Method);
callContextDictionary.Add("args", invocation.Arguments);
callContextDictionary.Add("target", invocation.Target);
@@ -195,7 +198,7 @@ namespace Spring.Aspects
return returnVal;
}
- private static void Sleep(RetryExceptionHandler handler, IDictionary callContextDictionary, SleepHandler sleepHandler)
+ private static void Sleep(RetryExceptionHandler handler, IDictionary callContextDictionary, SleepHandler sleepHandler)
{
if (handler.IsDelayBased)
{
diff --git a/src/Spring/Spring.Aop/Aspects/RetryExceptionHandler.cs b/src/Spring/Spring.Aop/Aspects/RetryExceptionHandler.cs
index 8961931b..b21b04d5 100644
--- a/src/Spring/Spring.Aop/Aspects/RetryExceptionHandler.cs
+++ b/src/Spring/Spring.Aop/Aspects/RetryExceptionHandler.cs
@@ -19,7 +19,7 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
namespace Spring.Aspects
{
@@ -119,7 +119,7 @@ namespace Spring.Aspects
///
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
///
- public override object HandleException(IDictionary callContextDictionary)
+ public override object HandleException(IDictionary callContextDictionary)
{
return null;
}
diff --git a/src/Spring/Spring.Aop/AssemblyInfo.cs b/src/Spring/Spring.Aop/AssemblyInfo.cs
index a9162360..52f74c86 100644
--- a/src/Spring/Spring.Aop/AssemblyInfo.cs
+++ b/src/Spring/Spring.Aop/AssemblyInfo.cs
@@ -1,4 +1,3 @@
-using System;
using System.Reflection;
[assembly: AssemblyTitle("Spring.Aop")]
diff --git a/src/Spring/Spring.Core/Caching/ICache.cs b/src/Spring/Spring.Core/Caching/ICache.cs
index 0afcc90e..5cbc3a45 100644
--- a/src/Spring/Spring.Core/Caching/ICache.cs
+++ b/src/Spring/Spring.Core/Caching/ICache.cs
@@ -59,13 +59,13 @@ namespace Spring.Caching
///
void Remove(object key);
- ///
- /// Removes collection of items from the cache.
- ///
- ///
- /// Collection of keys to remove.
- ///
- void RemoveAll(ICollection keys);
+ ///
+ /// Removes collection of items from the cache.
+ ///
+ ///
+ /// Collection of keys to remove.
+ ///
+ void RemoveAll(ICollection keys);
///
/// Removes all items from the cache.
diff --git a/src/Spring/Spring.Core/Caching/NonExpiringCache.cs b/src/Spring/Spring.Core/Caching/NonExpiringCache.cs
index 1d7a8f80..b55ce730 100644
--- a/src/Spring/Spring.Core/Caching/NonExpiringCache.cs
+++ b/src/Spring/Spring.Core/Caching/NonExpiringCache.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
namespace Spring.Caching
{
@@ -30,7 +31,8 @@ namespace Spring.Caching
/// Aleksandar Seovic
public class NonExpiringCache : AbstractCache
{
- private readonly IDictionary itemStore = new Hashtable();
+ private readonly object syncRoot = new object();
+ private readonly IDictionary itemStore = new Dictionary();
///
/// Gets the number of items in the cache.
@@ -39,7 +41,7 @@ namespace Spring.Caching
{
get
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
return itemStore.Count;
}
@@ -53,9 +55,9 @@ namespace Spring.Caching
{
get
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
- return itemStore.Keys;
+ return (ICollection) itemStore.Keys;
}
}
}
@@ -71,9 +73,11 @@ namespace Spring.Caching
///
public override object Get(object key)
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
- return itemStore[key];
+ object value;
+ itemStore.TryGetValue(key, out value);
+ return value;
}
}
@@ -85,7 +89,7 @@ namespace Spring.Caching
///
public override void Remove(object key)
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
itemStore.Remove(key);
}
@@ -99,7 +103,7 @@ namespace Spring.Caching
///
public override void RemoveAll(ICollection keys)
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
foreach (object key in keys)
{
@@ -113,7 +117,7 @@ namespace Spring.Caching
///
public override void Clear()
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
itemStore.Clear();
}
@@ -133,7 +137,7 @@ namespace Spring.Caching
///
protected override void DoInsert(object key, object value, TimeSpan timeToLive)
{
- lock (itemStore.SyncRoot)
+ lock (syncRoot)
{
itemStore[key] = value;
}
diff --git a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs
index 801c7d13..5d01f926 100644
--- a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs
+++ b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Common.Logging;
@@ -140,8 +141,8 @@ namespace Spring.Context.Support
private IEventRegistry _eventRegistry;
private IApplicationContext _parentApplicationContext;
- private readonly IList _objectFactoryPostProcessors;
- private readonly IList _defaultObjectPostProcessors;
+ private readonly IList _objectFactoryPostProcessors;
+ private readonly IList _defaultObjectPostProcessors;
private string _name;
private DateTime _startupDate;
private readonly bool _isCaseSensitive;
@@ -205,8 +206,8 @@ namespace Spring.Context.Support
_isCaseSensitive = caseSensitive;
_parentApplicationContext = parentApplicationContext;
EventRaiser = CreateEventRaiser();
- _objectFactoryPostProcessors = new ArrayList();
- _defaultObjectPostProcessors = new ArrayList();
+ _objectFactoryPostProcessors = new List();
+ _defaultObjectPostProcessors = new List();
AddDefaultObjectPostProcessor(new ObjectPostProcessorChecker());
AddDefaultObjectPostProcessor(new ApplicationContextAwareProcessor(this));
AddDefaultObjectPostProcessor(new SharedStateAwareProcessor(new ISharedStateFactory[] { new ByTypeSharedStateFactory() }, Int32.MaxValue));
@@ -406,7 +407,7 @@ namespace Spring.Context.Support
if (exceptions.HasExceptions)
{
Delegate target = ContextEvent.GetInvocationList()[0];
- Exception exception = (Exception)exceptions[target];
+ Exception exception = exceptions[target];
throw new ApplicationContextException(string.Format("An unhandled exception occured during processing application event {0} in handler {1}", e.GetType(), target.Method), exception);
}
}
@@ -490,20 +491,21 @@ namespace Spring.Context.Support
private void InvokeObjectFactoryPostProcessors(IConfigurableListableObjectFactory objectFactory)
{
// Invoke BeanDefinitionRegistryPostProcessors first, if any.
- ArrayList processedObjects = new ArrayList();
+ HashSet processedObjects = new HashSet();
if (objectFactory is IObjectDefinitionRegistry)
{
IObjectDefinitionRegistry registry = (IObjectDefinitionRegistry)objectFactory;
- ArrayList regularPostProcessors = new ArrayList();
- ArrayList registryPostProcessors = new ArrayList();
+ List regularPostProcessors = new List();
+ List registryPostProcessors = new List();
foreach (IObjectFactoryPostProcessor factoryProcessor in ObjectFactoryPostProcessors)
{
- if (factoryProcessor is IObjectDefinitionRegistryPostProcessor)
+ IObjectDefinitionRegistryPostProcessor registryPostProcessor = factoryProcessor as IObjectDefinitionRegistryPostProcessor;
+ if (registryPostProcessor != null)
{
- ((IObjectDefinitionRegistryPostProcessor)factoryProcessor).PostProcessObjectDefinitionRegistry(registry);
- registryPostProcessors.Add(factoryProcessor);
+ registryPostProcessor.PostProcessObjectDefinitionRegistry(registry);
+ registryPostProcessors.Add(registryPostProcessor);
}
else
{
@@ -511,12 +513,12 @@ namespace Spring.Context.Support
}
}
- IDictionary objectMap = objectFactory.GetObjectsOfType(typeof(IObjectDefinitionRegistryPostProcessor), true, false);
+ IDictionary objectMap = objectFactory.GetObjectsOfType(true, false);
- ArrayList registryPostProcessorObjects = new ArrayList(objectMap.Values);
+ List registryPostProcessorObjects = new List(objectMap.Values);
registryPostProcessorObjects.Sort(new OrderComparator());
- foreach (System.Object processor in registryPostProcessorObjects)
+ foreach (object processor in registryPostProcessorObjects)
{
((IObjectDefinitionRegistryPostProcessor)processor).PostProcessObjectDefinitionRegistry(registry);
}
@@ -527,7 +529,7 @@ namespace Spring.Context.Support
// processedObjects.Add(objectMap.Keys);
- foreach (DictionaryEntry entry in objectMap)
+ foreach (KeyValuePair entry in objectMap)
{
processedObjects.Add(entry.Key);
}
@@ -544,7 +546,7 @@ namespace Spring.Context.Support
// Do not initialize FactoryBeans here: We need to leave all regular beans
// uninitialized to let the bean factory post-processors apply to them!
- ArrayList factoryProcessorNames = new ArrayList();
+ List factoryProcessorNames = new List();
string[] names = GetObjectNamesForType(typeof(IObjectFactoryPostProcessor), true, false);
foreach (string name in names)
{
@@ -553,13 +555,13 @@ namespace Spring.Context.Support
// Separate between ObjectFactoryPostProcessors that implement PriorityOrdered,
// Ordered, and the rest.
- ArrayList priorityOrderedFactoryProcessors = new ArrayList();
- ArrayList orderedFactoryProcessorsNames = new ArrayList();
- ArrayList nonOrderedFactoryProcessorNames = new ArrayList();
+ List priorityOrderedFactoryProcessors = new List();
+ List orderedFactoryProcessorsNames = new List();
+ List nonOrderedFactoryProcessorNames = new List();
for (int i = 0; i < factoryProcessorNames.Count; ++i)
{
- string processorName = (string)factoryProcessorNames[i];
+ string processorName = factoryProcessorNames[i];
if (processedObjects.Contains(processorName))
{
//skip -- already processed in first phase above
@@ -567,7 +569,7 @@ namespace Spring.Context.Support
}
else if (IsTypeMatch(processorName, typeof(IPriorityOrdered)))
{
- priorityOrderedFactoryProcessors.Add(ObjectFactory.GetObject(processorName, typeof(IObjectFactoryPostProcessor)));
+ priorityOrderedFactoryProcessors.Add(ObjectFactory.GetObject(processorName));
}
else if (IsTypeMatch(processorName, typeof(IOrdered)))
{
@@ -582,21 +584,19 @@ namespace Spring.Context.Support
InvokePriorityOrderedObjectFactoryPostProcessors(factoryProcessorNames, priorityOrderedFactoryProcessors);
// Second, invoke those IObjectFactoryPostProcessors that implement IOrdered...
- ArrayList orderedFactoryProcessors = new ArrayList();
+ List orderedFactoryProcessors = new List();
foreach (string orderedFactoryProcessorsName in orderedFactoryProcessorsNames)
{
- orderedFactoryProcessors.Add(ObjectFactory.GetObject(orderedFactoryProcessorsName,
- typeof(IObjectFactoryPostProcessor)));
+ orderedFactoryProcessors.Add(ObjectFactory.GetObject(orderedFactoryProcessorsName));
}
orderedFactoryProcessors.Sort(new OrderComparator());
InvokeObjectFactoryPostProcessors(orderedFactoryProcessors, ObjectFactory);
// and then the unordered ones...
- ArrayList nonOrderedPostProcessors = new ArrayList();
+ List nonOrderedPostProcessors = new List();
foreach (string nonOrderedFactoryProcessorName in nonOrderedFactoryProcessorNames)
{
- nonOrderedPostProcessors.Add(ObjectFactory.GetObject(nonOrderedFactoryProcessorName,
- typeof(IObjectFactoryPostProcessor)));
+ nonOrderedPostProcessors.Add(ObjectFactory.GetObject(nonOrderedFactoryProcessorName));
}
InvokeObjectFactoryPostProcessors(nonOrderedPostProcessors, ObjectFactory);
@@ -614,7 +614,7 @@ namespace Spring.Context.Support
#endregion
}
- protected virtual void InvokePriorityOrderedObjectFactoryPostProcessors(ArrayList factoryProcessorNames, ArrayList priorityOrderedFactoryProcessors)
+ protected virtual void InvokePriorityOrderedObjectFactoryPostProcessors(List factoryProcessorNames, List priorityOrderedFactoryProcessors)
{
priorityOrderedFactoryProcessors.Sort(new OrderComparator());
InvokeObjectFactoryPostProcessors(priorityOrderedFactoryProcessors, ObjectFactory);
@@ -629,7 +629,7 @@ namespace Spring.Context.Support
{
if (IsTypeMatch(factoryProcessorName, typeof(IPriorityOrdered)))
{
- priorityOrderedFactoryProcessors.Add(ObjectFactory.GetObject(factoryProcessorName, typeof(IObjectFactoryPostProcessor)));
+ priorityOrderedFactoryProcessors.Add(ObjectFactory.GetObject(factoryProcessorName));
}
}
}
@@ -649,8 +649,8 @@ namespace Spring.Context.Support
private void RegisterObjectPostProcessors(IConfigurableListableObjectFactory objectFactory)
{
RefreshObjectPostProcessorChecker(objectFactory);
- IDictionary dict = GetObjectsOfType(typeof(IObjectPostProcessor), true, false);
- ArrayList objectProcessors = new ArrayList(dict.Values);
+ IDictionary dict = GetObjectsOfType(true, false);
+ List objectProcessors = new List(dict.Values);
// objectProcessors.Sort(new OrderComparator());
foreach (IObjectPostProcessor objectPostProcessor in objectProcessors)
{
@@ -733,8 +733,7 @@ namespace Spring.Context.Support
#endregion
}
- ICollection interestedParties
- = GetObjectsOfType(typeof(IEventRegistryAware), true, false).Values;
+ ICollection interestedParties = GetObjectsOfType(true, false).Values;
foreach (IEventRegistryAware party in interestedParties)
{
party.EventRegistry = EventRegistry;
@@ -857,9 +856,7 @@ namespace Spring.Context.Support
private void RefreshApplicationEventListeners()
{
- ICollection listeners
- = GetObjectsOfType(
- typeof(IApplicationEventListener), true, false).Values;
+ ICollection listeners = GetObjectsOfType(true, false).Values;
foreach (IApplicationEventListener applicationListener in listeners)
{
EventRegistry.Subscribe(applicationListener);
@@ -883,7 +880,7 @@ namespace Spring.Context.Support
/// s
/// that will be applied to the objects created with this factory.
///
- private IList ObjectFactoryPostProcessors
+ private IList ObjectFactoryPostProcessors
{
get { return _objectFactoryPostProcessors; }
}
@@ -1056,7 +1053,7 @@ namespace Spring.Context.Support
// index 0 contains the ObjectPostProcessorChecker that is handled separately!
for (int i = 1; i < _defaultObjectPostProcessors.Count; i++)
{
- objectFactory.AddObjectPostProcessor((IObjectPostProcessor)this._defaultObjectPostProcessors[i]);
+ objectFactory.AddObjectPostProcessor(this._defaultObjectPostProcessors[i]);
}
}
@@ -1088,11 +1085,11 @@ namespace Spring.Context.Support
///
public void Start()
{
- IDictionary lifecycleObjects = LifeCycleObjects;
- foreach (DictionaryEntry dictionaryEntry in lifecycleObjects)
+ IDictionary lifecycleObjects = LifeCycleObjects;
+ foreach (KeyValuePair dictionaryEntry in lifecycleObjects)
{
//TODO start dependencies of the lifecycle objects
- ILifecycle obj = dictionaryEntry.Value as ILifecycle;
+ ILifecycle obj = dictionaryEntry.Value;
if (obj != null)
{
if (!obj.IsRunning)
@@ -1113,11 +1110,11 @@ namespace Spring.Context.Support
///
public void Stop()
{
- IDictionary lifecycleObjects = LifeCycleObjects;
- foreach (DictionaryEntry dictionaryEntry in lifecycleObjects)
+ IDictionary lifecycleObjects = LifeCycleObjects;
+ foreach (KeyValuePair dictionaryEntry in lifecycleObjects)
{
//TODO stop dependencies of the lifecycle objects
- ILifecycle obj = dictionaryEntry.Value as ILifecycle;
+ ILifecycle obj = dictionaryEntry.Value;
if (obj != null)
{
if (obj.IsRunning)
@@ -1142,10 +1139,10 @@ namespace Spring.Context.Support
{
get
{
- IDictionary lifecycleObjects = LifeCycleObjects;
- foreach (DictionaryEntry dictionaryEntry in lifecycleObjects)
+ IDictionary lifecycleObjects = LifeCycleObjects;
+ foreach (KeyValuePair dictionaryEntry in lifecycleObjects)
{
- ILifecycle obj = dictionaryEntry.Value as ILifecycle;
+ ILifecycle obj = dictionaryEntry.Value;
if (obj != null)
{
if (!obj.IsRunning)
@@ -1163,19 +1160,19 @@ namespace Spring.Context.Support
/// ILifecycle interface in this context.
///
/// A dictionary of ILifecycle objects with object name as key.
- private IDictionary LifeCycleObjects
+ private IDictionary LifeCycleObjects
{
get
{
IConfigurableListableObjectFactory objectFactory = ObjectFactory;
string[] objectNames = objectFactory.SingletonNames;
- IDictionary lifeCycleObjects = new Hashtable();
+ IDictionary lifeCycleObjects = new Dictionary();
foreach (string objectName in objectNames)
{
object obj = objectFactory.GetSingleton(objectName);
if (obj is ILifecycle)
{
- lifeCycleObjects[objectName] = obj;
+ lifeCycleObjects[objectName] = (ILifecycle) obj;
}
}
return lifeCycleObjects;
@@ -1413,7 +1410,7 @@ namespace Spring.Context.Support
/// If the objects could not be created.
///
///
- public IDictionary GetObjectsOfType(Type type)
+ public IDictionary GetObjectsOfType(Type type)
{
return GetObjectsOfType(type, true, true);
}
@@ -1445,9 +1442,9 @@ namespace Spring.Context.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType()
+ public IDictionary GetObjectsOfType()
{
- return GetObjectsOfType(typeof(T));
+ return (IDictionary) GetObjectsOfType(typeof(T));
}
///
@@ -1477,7 +1474,7 @@ namespace Spring.Context.Support
/// If the objects could not be created.
///
///
- public IDictionary GetObjectsOfType(
+ public IDictionary GetObjectsOfType(
Type type, bool includePrototypes, bool includeFactoryObjects)
{
return ObjectFactory.GetObjectsOfType(type, includePrototypes, includeFactoryObjects);
@@ -1494,12 +1491,12 @@ namespace Spring.Context.Support
/// The (class or interface) to match.
///
///
- /// Whether to include prototype objects too or just singletons (also applies to
- /// s).
+ /// Whether to include prototype objects too or just singletons (also applies to
+ /// s).
///
///
- /// Whether to include s too
- /// or just normal objects.
+ /// Whether to include s too
+ /// or just normal objects.
///
///
/// A of the matching objects,
@@ -1509,9 +1506,9 @@ namespace Spring.Context.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
{
- return GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects);
+ return ObjectFactory.GetObjectsOfType(includePrototypes, includeFactoryObjects);
}
///
diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs
index 447031bb..4c5ce413 100644
--- a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs
+++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContext.cs
@@ -22,8 +22,7 @@
using System;
using System.IO;
-using System.Threading;
-using Common.Logging;
+
using Spring.Objects;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
index f5bac768..68e9ec8e 100644
--- a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
+++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
@@ -18,7 +18,6 @@
#endregion
-using System;
using Spring.Core.IO;
namespace Spring.Context.Support
diff --git a/src/Spring/Spring.Core/Context/Support/ApplicationContextAwareProcessor.cs b/src/Spring/Spring.Core/Context/Support/ApplicationContextAwareProcessor.cs
index f27e7b83..fa9a766e 100644
--- a/src/Spring/Spring.Core/Context/Support/ApplicationContextAwareProcessor.cs
+++ b/src/Spring/Spring.Core/Context/Support/ApplicationContextAwareProcessor.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using System.Runtime.Remoting;
using Spring.Objects.Factory.Config;
diff --git a/src/Spring/Spring.Core/Context/Support/ApplicationObjectSupport.cs b/src/Spring/Spring.Core/Context/Support/ApplicationObjectSupport.cs
index b535bd80..bb1cdf8b 100644
--- a/src/Spring/Spring.Core/Context/Support/ApplicationObjectSupport.cs
+++ b/src/Spring/Spring.Core/Context/Support/ApplicationObjectSupport.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Globalization;
+
using Spring.Objects;
#endregion
diff --git a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
index 0c21fed1..bee696a3 100644
--- a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
+++ b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs
@@ -20,16 +20,15 @@
#region Imports
-using System;
-using System.Collections;
+using System;
+using System.Collections.Generic;
using System.Configuration;
using System.Reflection;
using System.Xml;
using Common.Logging;
using Spring.Core;
-using Spring.Core.TypeResolution;
-using Spring.Objects;
+using Spring.Core.TypeResolution;
using Spring.Reflection.Dynamic;
using Spring.Util;
@@ -448,8 +447,8 @@ namespace Spring.Context.Support
/// this context.
///
private string[] GetResources( XmlElement contextElement )
- {
- ArrayList resourceNodes = new ArrayList(contextElement.ChildNodes.Count);
+ {
+ List resourceNodes = new List(contextElement.ChildNodes.Count);
foreach (XmlNode possibleResourceNode in contextElement.ChildNodes)
{
XmlElement possibleResourceElement = possibleResourceNode as XmlElement;
@@ -463,15 +462,15 @@ namespace Spring.Context.Support
}
}
}
- return (string[]) resourceNodes.ToArray(typeof(string));
+ return resourceNodes.ToArray();
}
///
/// Returns the array of child contexts for this context.
///
private XmlNode[] GetChildContexts(XmlElement contextElement)
- {
- ArrayList contextNodes = new ArrayList(contextElement.ChildNodes.Count);
+ {
+ List contextNodes = new List(contextElement.ChildNodes.Count);
foreach (XmlNode possibleContextNode in contextElement.ChildNodes)
{
XmlElement possibleContextElement = possibleContextNode as XmlElement;
@@ -481,7 +480,7 @@ namespace Spring.Context.Support
contextNodes.Add(possibleContextElement);
}
}
- return (XmlNode[])contextNodes.ToArray(typeof(XmlNode));
+ return contextNodes.ToArray();
}
#region Inner Class : ContextInstantiator
diff --git a/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs b/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs
index e04191c1..73e1600f 100644
--- a/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs
+++ b/src/Spring/Spring.Core/Context/Support/ContextRegistry.cs
@@ -21,14 +21,12 @@
#region Imports
using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Configuration;
+using System.Collections.Generic;
+
using Common.Logging;
+
using Spring.Context.Events;
using Spring.Util;
-using Spring.Objects.Factory;
-using Spring.Objects.Factory.Support;
#endregion
@@ -63,7 +61,7 @@ namespace Spring.Context.Support
private static readonly ContextRegistry instance = new ContextRegistry();
private static string rootContextName = null;
- private IDictionary contextMap = CollectionsUtil.CreateCaseInsensitiveHashtable();
+ private IDictionary contextMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
#region Constructor (s) / Destructor
@@ -108,7 +106,7 @@ namespace Spring.Context.Support
{
IApplicationContext parent = context.ParentContext;
- Hashtable contexts = new Hashtable();
+ Dictionary contexts = new Dictionary();
int contextIndex = 0;
@@ -125,7 +123,7 @@ namespace Spring.Context.Support
for (int i = contextIndex; i > 0; i--)
{
- IApplicationContext contextToUpdate = (IApplicationContext)contexts[i];
+ IApplicationContext contextToUpdate = contexts[i];
if (prefix != string.Empty)
prefix = string.Format("{0}/{1}", prefix, contextToUpdate.Name);
@@ -171,22 +169,20 @@ namespace Spring.Context.Support
lock (syncRoot)
{
- if (instance.contextMap.Contains(context.Name))
+ IApplicationContext ctx;
+ if (instance.contextMap.TryGetValue(context.Name, out ctx))
{
- IApplicationContext ctx = (IApplicationContext)instance.contextMap[context.Name];
- throw new ApplicationContextException(
- string.Format("Existing context '{0}' already registered under name '{1}'.",
- ctx, context.Name));
+ throw new ApplicationContextException(string.Format("Existing context '{0}' already registered under name '{1}'.", ctx, context.Name));
}
+
instance.contextMap[context.Name] = context;
- context.ContextEvent += new ApplicationEventHandler(OnContextEvent);
+ context.ContextEvent += OnContextEvent;
#region Instrumentation
if (log.IsDebugEnabled)
{
- log.Debug(String.Format(
- "Registering context '{0}' under name '{1}'.", context, context.Name));
+ log.Debug(String.Format("Registering context '{0}' under name '{1}'.", context, context.Name));
}
#endregion
@@ -290,8 +286,8 @@ namespace Spring.Context.Support
lock (syncRoot)
{
InitializeContextIfNeeded();
- IApplicationContext ctx = (IApplicationContext)instance.contextMap[name];
- if (ctx == null)
+ IApplicationContext ctx;
+ if (!instance.contextMap.TryGetValue(name, out ctx))
{
throw new ApplicationContextException(String.Format(
"No context registered under name '{0}'. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.",
@@ -325,7 +321,7 @@ namespace Spring.Context.Support
{
lock (syncRoot)
{
- ArrayList contexts = new ArrayList(instance.contextMap.Values);
+ ICollection contexts = new List(instance.contextMap.Values);
foreach (IApplicationContext ctx in contexts)
{
ctx.Dispose();
@@ -369,7 +365,9 @@ namespace Spring.Context.Support
{
lock (instance)
{
- return (instance.contextMap[name] != null);
+ IApplicationContext temp;
+ instance.contextMap.TryGetValue(name, out temp);
+ return temp != null;
}
}
diff --git a/src/Spring/Spring.Core/Context/Support/MessageSourceAccessor.cs b/src/Spring/Spring.Core/Context/Support/MessageSourceAccessor.cs
index f665b1c8..acae5d81 100644
--- a/src/Spring/Spring.Core/Context/Support/MessageSourceAccessor.cs
+++ b/src/Spring/Spring.Core/Context/Support/MessageSourceAccessor.cs
@@ -20,7 +20,6 @@
#region Imports
-using System;
using System.Globalization;
#endregion
diff --git a/src/Spring/Spring.Core/Context/Support/ResourceSetMessageSource.cs b/src/Spring/Spring.Core/Context/Support/ResourceSetMessageSource.cs
index 841e558b..d23a0ebf 100644
--- a/src/Spring/Spring.Core/Context/Support/ResourceSetMessageSource.cs
+++ b/src/Spring/Spring.Core/Context/Support/ResourceSetMessageSource.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Resources;
@@ -49,8 +49,8 @@ namespace Spring.Context.Support
{
#region Fields
- private Hashtable _cachedResources;
- private IList _resourceManagers;
+ private Dictionary _cachedResources;
+ private IList _resourceManagers;
#endregion
@@ -60,15 +60,15 @@ namespace Spring.Context.Support
///
public ResourceSetMessageSource()
{
- _cachedResources = new Hashtable();
- _resourceManagers = new ArrayList();
+ _cachedResources = new Dictionary();
+ _resourceManagers = new List();
}
///
/// The collection of s
/// in this .
///
- public IList ResourceManagers
+ public IList ResourceManagers
{
get { return _resourceManagers; }
set { _resourceManagers = value; }
@@ -160,9 +160,9 @@ namespace Spring.Context.Support
protected object ResolveObject(ResourceManager resourceManager, string code, CultureInfo cultureInfo)
{
string cacheKey = code + "." + cultureInfo.Name;
- object resource = _cachedResources[cacheKey];
+ object resource;
- if (resource == null)
+ if (!_cachedResources.TryGetValue(cacheKey, out resource))
{
resource = resourceManager.GetObject(code, cultureInfo);
if (resource != null)
diff --git a/src/Spring/Spring.Core/Context/Support/StaticMessageSource.cs b/src/Spring/Spring.Core/Context/Support/StaticMessageSource.cs
index b9aa9fd8..121fb268 100644
--- a/src/Spring/Spring.Core/Context/Support/StaticMessageSource.cs
+++ b/src/Spring/Spring.Core/Context/Support/StaticMessageSource.cs
@@ -20,7 +20,7 @@
#region Imports
-using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Text;
@@ -47,8 +47,8 @@ namespace Spring.Context.Support
///
public class StaticMessageSource : AbstractMessageSource
{
- private Hashtable _messages;
- private Hashtable _objects;
+ private Dictionary _messages;
+ private Dictionary _objects;
///
/// Creates a new instance of the
@@ -56,8 +56,8 @@ namespace Spring.Context.Support
///
public StaticMessageSource()
{
- _messages = new Hashtable();
- _objects = new Hashtable();
+ _messages = new Dictionary();
+ _objects = new Dictionary();
}
///
@@ -73,11 +73,14 @@ namespace Spring.Context.Support
///
///
protected override string ResolveMessage(string code, CultureInfo cultureInfo)
- {
- return (string) _messages[GetLookupKey(code, cultureInfo)];
- }
+ {
+ string key = GetLookupKey(code, cultureInfo);
+ string message;
+ _messages.TryGetValue(key, out message);
+ return message;
+ }
- ///
+ ///
/// Resolves an object (typically an icon or bitmap).
///
/// The code of the object to resolve.
@@ -91,7 +94,10 @@ namespace Spring.Context.Support
///
protected override object ResolveObject(string code, CultureInfo cultureInfo)
{
- return _objects[GetLookupKey(code, cultureInfo)];
+ string key = GetLookupKey(code, cultureInfo);
+ object obj;
+ _objects.TryGetValue(key, out obj);
+ return obj;
}
diff --git a/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
index f4dffe1b..bdc3365e 100644
--- a/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
+++ b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
@@ -18,7 +18,6 @@
#endregion
-using System;
using Spring.Core.IO;
namespace Spring.Context.Support
diff --git a/src/Spring/Spring.Core/Core/ComposedCriteria.cs b/src/Spring/Spring.Core/Core/ComposedCriteria.cs
index 8d6e12c9..0086fd69 100644
--- a/src/Spring/Spring.Core/Core/ComposedCriteria.cs
+++ b/src/Spring/Spring.Core/Core/ComposedCriteria.cs
@@ -21,6 +21,7 @@
#region Imports
using System.Collections;
+using System.Collections.Generic;
using Spring.Core;
#endregion
@@ -52,7 +53,7 @@ namespace Spring.Core
///
public ComposedCriteria(ICriteria criteria)
{
- _criteria = new ArrayList();
+ _criteria = new List();
Add(criteria);
}
@@ -102,14 +103,14 @@ namespace Spring.Core
/// The list of composing this
/// instance.
///
- protected IList Criteria
+ protected IList Criteria
{
get { return _criteria; }
}
#region Fields
- private IList _criteria;
+ private IList _criteria;
#endregion
}
diff --git a/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs b/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs
index 244dd81d..78e5a851 100644
--- a/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs
+++ b/src/Spring/Spring.Core/Core/IO/ResourceConverter.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using Common.Logging;
@@ -170,7 +170,7 @@ namespace Spring.Core.IO
protected virtual string ResolvePath(string path)
{
// quite inefficient, but cost is only ever paid once at startup...
- IList expressions = StringUtils.GetAntExpressions(path);
+ IList expressions = StringUtils.GetAntExpressions(path);
foreach (string expression in expressions)
{
string environmentValue
diff --git a/src/Spring/Spring.Core/Core/IO/ResourceHandlerRegistry.cs b/src/Spring/Spring.Core/Core/IO/ResourceHandlerRegistry.cs
index f4ed3a39..1721c561 100644
--- a/src/Spring/Spring.Core/Core/IO/ResourceHandlerRegistry.cs
+++ b/src/Spring/Spring.Core/Core/IO/ResourceHandlerRegistry.cs
@@ -19,10 +19,10 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
-using System.Security;
using System.Security.Permissions;
+
using Spring.Context.Support;
using Spring.Core.TypeResolution;
using Spring.Util;
@@ -102,14 +102,15 @@ namespace Spring.Core.IO
///
private const string ResourcesSectionName = "spring/resourceHandlers";
- private static IDictionary resourceHandlers = new Hashtable();
+ private static object syncRoot = new object();
+ private static IDictionary resourceHandlers = new Dictionary();
///
/// Registers standard and user-configured resource handlers.
///
static ResourceHandlerRegistry()
{
- lock (resourceHandlers.SyncRoot)
+ lock (syncRoot)
{
RegisterResourceHandler("config", typeof(ConfigSectionResource));
RegisterResourceHandler("file", typeof(FileSystemResource));
@@ -139,7 +140,9 @@ namespace Spring.Core.IO
public static IDynamicConstructor GetResourceHandler(string protocolName)
{
AssertUtils.ArgumentNotNull(protocolName, "protocolName");
- return (IDynamicConstructor)resourceHandlers[protocolName];
+ IDynamicConstructor constructor;
+ resourceHandlers.TryGetValue(protocolName, out constructor);
+ return constructor;
}
///
@@ -153,7 +156,7 @@ namespace Spring.Core.IO
/// If is null.
public static bool IsHandlerRegistered(string protocolName)
{
- return resourceHandlers.Contains(protocolName);
+ return resourceHandlers.ContainsKey(protocolName);
}
///
@@ -241,7 +244,7 @@ namespace Spring.Core.IO
#endregion
- lock (resourceHandlers.SyncRoot)
+ lock (syncRoot)
{
SecurityCritical.ExecutePrivileged( new SecurityPermission(SecurityPermissionFlag.Infrastructure), delegate
{
diff --git a/src/Spring/Spring.Core/Core/OrderComparator.cs b/src/Spring/Spring.Core/Core/OrderComparator.cs
index 7ecb4a33..fce0212b 100644
--- a/src/Spring/Spring.Core/Core/OrderComparator.cs
+++ b/src/Spring/Spring.Core/Core/OrderComparator.cs
@@ -22,27 +22,46 @@
using System;
using System.Collections;
+using System.Collections.Generic;
#endregion
namespace Spring.Core
{
- ///
- /// Comparator implementation for objects, sorting by
- /// order value ascending (resp. by priority descending).
- ///
- ///
- ///
- /// Non- objects are treated as greatest order values,
- /// thus ending up at the end of a list, in arbitrary order (just like same order values of
- /// objects).
- ///
- ///
- /// Juergen Hoeller
+ ///
+ /// Comparator implementation for objects, sorting by
+ /// order value ascending (resp. by priority descending).
+ ///
+ ///
+ ///
+ /// Non- objects are treated as greatest order values,
+ /// thus ending up at the end of a list, in arbitrary order (just like same order values of
+ /// objects).
+ ///
+ ///
+ /// Juergen Hoeller
/// Aleksandar Seovic (.Net)
[Serializable]
- public class OrderComparator : IComparer
- {
+ public class OrderComparator : OrderComparator, IComparer
+ {
+ }
+
+ ///
+ /// Comparator implementation for objects, sorting by
+ /// order value ascending (resp. by priority descending).
+ ///
+ ///
+ ///
+ /// Non- objects are treated as greatest order values,
+ /// thus ending up at the end of a list, in arbitrary order (just like same order values of
+ /// objects).
+ ///
+ ///
+ /// Juergen Hoeller
+ /// Aleksandar Seovic (.Net)
+ [Serializable]
+ public class OrderComparator : IComparer
+ {
///
/// Compares two objects and returns a value indicating whether one is less than,
/// equal to or greater than the other.
@@ -58,12 +77,12 @@ namespace Spring.Core
///
/// -1 if first object is less then second, 1 if it is greater, or 0 if they are equal.
///
- public virtual int Compare(object o1, object o2)
- {
- IOrdered o1lhs = o1 as IOrdered;
- IOrdered o2rhs = o2 as IOrdered;
- int lhs = o1lhs != null ? o1lhs.Order : Int32.MaxValue;
- int rhs = o2rhs != null ? o2rhs.Order : Int32.MaxValue;
+ public virtual int Compare(T o1, T o2)
+ {
+ IOrdered o1lhs = o1 as IOrdered;
+ IOrdered o2rhs = o2 as IOrdered;
+ int lhs = o1lhs != null ? o1lhs.Order : Int32.MaxValue;
+ int rhs = o2rhs != null ? o2rhs.Order : Int32.MaxValue;
if (lhs < rhs)
{
return - 1;
@@ -76,7 +95,7 @@ namespace Spring.Core
{
return CompareEqualOrder(o1, o2);
}
- }
+ }
///
/// Handle the case when both objects have equal sort order priority. By default returns 0,
@@ -87,9 +106,9 @@ namespace Spring.Core
///
/// -1 if first object is less then second, 1 if it is greater, or 0 if they are equal.
///
- protected virtual int CompareEqualOrder(object o1, object o2)
+ protected virtual int CompareEqualOrder(T o1, T o2)
{
return 0;
}
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Core/TypeConversion/TypeConverterRegistry.cs b/src/Spring/Spring.Core/Core/TypeConversion/TypeConverterRegistry.cs
index d5a5a4c2..0ebb87e2 100644
--- a/src/Spring/Spring.Core/Core/TypeConversion/TypeConverterRegistry.cs
+++ b/src/Spring/Spring.Core/Core/TypeConversion/TypeConverterRegistry.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
@@ -29,9 +29,9 @@ using System.IO;
using System.Net;
using System.Resources;
using System.Text.RegularExpressions;
+
using Microsoft.Win32;
-using Spring.Core;
using Spring.Core.TypeResolution;
using Spring.Util;
@@ -50,14 +50,15 @@ namespace Spring.Core.TypeConversion
///
private const string TypeConvertersSectionName = "spring/typeConverters";
- private static IDictionary converters = new Hashtable();
+ private static readonly object syncRoot = new object();
+ private static IDictionary converters = new Dictionary();
///
/// Registers standard and configured type converters.
///
static TypeConverterRegistry()
{
- lock (converters.SyncRoot)
+ lock (syncRoot)
{
converters[typeof(string[])] = new StringArrayConverter();
converters[typeof(Type)] = new RuntimeTypeConverter();
@@ -88,8 +89,8 @@ namespace Spring.Core.TypeConversion
{
AssertUtils.ArgumentNotNull(type, "type");
- TypeConverter converter = (TypeConverter) converters[type];
- if (converter == null)
+ TypeConverter converter;
+ if (!converters.TryGetValue(type, out converter))
{
if (type.IsEnum)
{
@@ -115,7 +116,7 @@ namespace Spring.Core.TypeConversion
AssertUtils.ArgumentNotNull(type, "type");
AssertUtils.ArgumentNotNull(converter, "converter");
- lock (converters.SyncRoot)
+ lock (syncRoot)
{
converters[type] = converter;
}
diff --git a/src/Spring/Spring.Core/Core/TypeResolution/TypeRegistry.cs b/src/Spring/Spring.Core/Core/TypeResolution/TypeRegistry.cs
index 049a8ed5..15e5f55e 100644
--- a/src/Spring/Spring.Core/Core/TypeResolution/TypeRegistry.cs
+++ b/src/Spring/Spring.Core/Core/TypeResolution/TypeRegistry.cs
@@ -21,9 +21,8 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
-using Spring.Core;
using Spring.Util;
#endregion
@@ -430,7 +429,8 @@ namespace Spring.Core.TypeResolution
#region Fields
- private static IDictionary types = new Hashtable();
+ private static readonly object syncRoot = new object();
+ private static IDictionary types = new Dictionary();
#endregion
@@ -441,7 +441,7 @@ namespace Spring.Core.TypeResolution
///
static TypeRegistry()
{
- lock (types.SyncRoot)
+ lock (syncRoot)
{
types["Int32"] = typeof(Int32);
types[Int32Alias] = typeof(Int32);
@@ -608,8 +608,8 @@ namespace Spring.Core.TypeResolution
public static void RegisterType(Type type)
{
AssertUtils.ArgumentNotNull(type, "type");
-
- lock (types.SyncRoot)
+
+ lock (syncRoot)
{
types[type.Name] = type;
}
@@ -634,7 +634,7 @@ namespace Spring.Core.TypeResolution
AssertUtils.ArgumentHasText(alias, "alias");
AssertUtils.ArgumentNotNull(type, "type");
- lock (types.SyncRoot)
+ lock (syncRoot)
{
types[alias] = type;
}
@@ -658,7 +658,9 @@ namespace Spring.Core.TypeResolution
public static Type ResolveType(string alias)
{
AssertUtils.ArgumentHasText(alias, "alias");
- return (Type) types[alias];
+ Type type;
+ types.TryGetValue(alias, out type);
+ return type;
}
///
@@ -674,7 +676,7 @@ namespace Spring.Core.TypeResolution
///
public static bool ContainsAlias(string alias)
{
- return types.Contains(alias);
+ return types.ContainsKey(alias);
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs b/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs
index 7b967cf7..cfdf4b20 100644
--- a/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs
+++ b/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Reflection;
@@ -126,7 +127,7 @@ namespace Spring.Core.TypeResolution
{
AssertUtils.ArgumentNotNull(interfaceNames, "interfaceNames");
- ArrayList interfaces = new ArrayList();
+ List interfaces = new List();
for (int i = 0; i < interfaceNames.Length; i++)
{
string interfaceName = interfaceNames[i];
@@ -143,7 +144,7 @@ namespace Spring.Core.TypeResolution
interfaces.Add(resolvedInterface);
interfaces.AddRange(resolvedInterface.GetInterfaces());
}
- return (Type[])interfaces.ToArray(typeof(Type));
+ return interfaces.ToArray();
}
#region MethodMatch
diff --git a/src/Spring/Spring.Core/DataBinding/AbstractBinding.cs b/src/Spring/Spring.Core/DataBinding/AbstractBinding.cs
index 4ab51109..896b81a9 100644
--- a/src/Spring/Spring.Core/DataBinding/AbstractBinding.cs
+++ b/src/Spring/Spring.Core/DataBinding/AbstractBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Spring.Collections;
using Spring.Util;
using Spring.Validation;
@@ -41,7 +42,7 @@ namespace Spring.DataBinding
{
if (errors == null) return true;
- IList errorList = errors.GetErrors(ALL_BINDINGERRORS_PROVIDER);
+ IList errorList = errors.GetErrors(ALL_BINDINGERRORS_PROVIDER);
return (errorList == null) || (!errorList.Contains(this.ErrorMessage));
}
@@ -150,35 +151,35 @@ namespace Spring.DataBinding
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public abstract void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
+ public abstract void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
///
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public abstract void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
+ public abstract void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
///
/// Sets error message that should be displayed in the case
diff --git a/src/Spring/Spring.Core/DataBinding/AbstractSimpleBinding.cs b/src/Spring/Spring.Core/DataBinding/AbstractSimpleBinding.cs
index f87f6d84..a45dd4eb 100644
--- a/src/Spring/Spring.Core/DataBinding/AbstractSimpleBinding.cs
+++ b/src/Spring/Spring.Core/DataBinding/AbstractSimpleBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Common.Logging;
using Spring.Globalization;
@@ -60,19 +61,18 @@ namespace Spring.DataBinding
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
if (this.IsValid(validationErrors)
&& (this.Direction == BindingDirection.Bidirectional || this.Direction == BindingDirection.SourceToTarget))
@@ -92,15 +92,15 @@ namespace Spring.DataBinding
/// Concrete implementation if source to target binding.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- protected virtual void DoBindSourceToTarget(object source, object target, IDictionary variables)
+ protected virtual void DoBindSourceToTarget(object source, object target, IDictionary variables)
{
object value = this.GetSourceValue(source, variables);
if (this.Formatter != null && value is string)
@@ -114,19 +114,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
if (this.IsValid(validationErrors)
&& (this.Direction == BindingDirection.Bidirectional || this.Direction == BindingDirection.TargetToSource))
@@ -147,15 +146,15 @@ namespace Spring.DataBinding
/// Concrete implementation of target to source binding.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- protected virtual void DoBindTargetToSource(object source, object target, IDictionary variables)
+ protected virtual void DoBindTargetToSource(object source, object target, IDictionary variables)
{
object value = this.GetTargetValue(target, variables);
if (this.Formatter != null)
@@ -173,57 +172,57 @@ namespace Spring.DataBinding
/// Gets the source value for the binding.
///
///
- /// Source object to extract value from.
+ /// Source object to extract value from.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
///
/// The source value for the binding.
///
- protected abstract object GetSourceValue(object source, IDictionary variables);
+ protected abstract object GetSourceValue(object source, IDictionary variables);
///
/// Sets the source value for the binding.
///
///
- /// The source object to set the value on.
+ /// The source object to set the value on.
///
///
- /// The value to set.
+ /// The value to set.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
- protected abstract void SetSourceValue(object source, object value, IDictionary variables);
+ protected abstract void SetSourceValue(object source, object value, IDictionary variables);
///
/// Gets the target value for the binding.
///
///
- /// Source object to extract value from.
+ /// Source object to extract value from.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
///
/// The target value for the binding.
///
- protected abstract object GetTargetValue(object target, IDictionary variables);
+ protected abstract object GetTargetValue(object target, IDictionary variables);
///
/// Sets the target value for the binding.
///
///
- /// The target object to set the value on.
+ /// The target object to set the value on.
///
///
- /// The value to set.
+ /// The value to set.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
- protected abstract void SetTargetValue(object target, object value, IDictionary variables);
+ protected abstract void SetTargetValue(object target, object value, IDictionary variables);
#endregion
}
diff --git a/src/Spring/Spring.Core/DataBinding/BaseBindingContainer.cs b/src/Spring/Spring.Core/DataBinding/BaseBindingContainer.cs
index cea5c281..7ee1b14b 100644
--- a/src/Spring/Spring.Core/DataBinding/BaseBindingContainer.cs
+++ b/src/Spring/Spring.Core/DataBinding/BaseBindingContainer.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Generic;
using Spring.Globalization;
using Spring.Validation;
@@ -12,7 +13,7 @@ namespace Spring.DataBinding
{
#region Fields
- private IList bindings = new ArrayList();
+ private IList bindings = new List();
#endregion
@@ -34,7 +35,7 @@ namespace Spring.DataBinding
///
/// A list of bindings for this container.
///
- protected IList Bindings
+ protected IList Bindings
{
get { return bindings; }
}
@@ -182,19 +183,18 @@ namespace Spring.DataBinding
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public virtual void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public virtual void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
foreach (IBinding binding in bindings)
{
@@ -223,19 +223,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public virtual void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public virtual void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
foreach (IBinding binding in bindings)
{
diff --git a/src/Spring/Spring.Core/DataBinding/IBinding.cs b/src/Spring/Spring.Core/DataBinding/IBinding.cs
index 2bf89bed..2e310fb3 100644
--- a/src/Spring/Spring.Core/DataBinding/IBinding.cs
+++ b/src/Spring/Spring.Core/DataBinding/IBinding.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Generic;
using Spring.Validation;
namespace Spring.DataBinding
@@ -27,18 +28,18 @@ namespace Spring.DataBinding
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
+ void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
///
/// Binds target object to source object.
@@ -58,18 +59,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
+ void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
///
/// Sets error message that should be displayed in the case
diff --git a/src/Spring/Spring.Core/DataBinding/ListBinding.cs b/src/Spring/Spring.Core/DataBinding/ListBinding.cs
index b22a3373..7e942379 100644
--- a/src/Spring/Spring.Core/DataBinding/ListBinding.cs
+++ b/src/Spring/Spring.Core/DataBinding/ListBinding.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
using Spring.Validation;
@@ -14,28 +15,27 @@ namespace Spring.DataBinding
{
private IExpression sourceExpression = Expression.Parse("#source = #target");
private IExpression targetExpression = Expression.Parse("#target = #source");
-
+
///
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
if (variables == null)
{
- variables = new Hashtable();
+ variables = new Dictionary();
}
variables["source"] = source;
variables["target"] = target;
@@ -47,23 +47,22 @@ namespace Spring.DataBinding
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
- IDictionary variables)
+ public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
if (variables == null)
{
- variables = new Hashtable();
+ variables = new Dictionary();
}
variables["source"] = source;
variables["target"] = target;
diff --git a/src/Spring/Spring.Core/DataBinding/SimpleExpressionBinding.cs b/src/Spring/Spring.Core/DataBinding/SimpleExpressionBinding.cs
index bde2738a..af507f86 100644
--- a/src/Spring/Spring.Core/DataBinding/SimpleExpressionBinding.cs
+++ b/src/Spring/Spring.Core/DataBinding/SimpleExpressionBinding.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
using Spring.Globalization;
@@ -104,15 +105,15 @@ namespace Spring.DataBinding
/// Gets the source value for the binding.
///
///
- /// Source object to extract value from.
+ /// Source object to extract value from.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
///
/// The source value for the binding.
///
- protected override object GetSourceValue(object source, IDictionary variables)
+ protected override object GetSourceValue(object source, IDictionary variables)
{
return this.SourceExpression.GetValue(source, variables);
}
@@ -121,15 +122,15 @@ namespace Spring.DataBinding
/// Sets the source value for the binding.
///
///
- /// The source object to set the value on.
+ /// The source object to set the value on.
///
///
- /// The value to set.
+ /// The value to set.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
- protected override void SetSourceValue(object source, object value, IDictionary variables)
+ protected override void SetSourceValue(object source, object value, IDictionary variables)
{
this.SourceExpression.SetValue(source, variables, value);
}
@@ -138,15 +139,15 @@ namespace Spring.DataBinding
/// Gets the target value for the binding.
///
///
- /// Source object to extract value from.
+ /// Source object to extract value from.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
///
/// The target value for the binding.
///
- protected override object GetTargetValue(object target, IDictionary variables)
+ protected override object GetTargetValue(object target, IDictionary variables)
{
return this.TargetExpression.GetValue(target, variables);
}
@@ -155,15 +156,15 @@ namespace Spring.DataBinding
/// Sets the target value for the binding.
///
///
- /// The target object to set the value on.
+ /// The target object to set the value on.
///
///
- /// The value to set.
+ /// The value to set.
///
///
- /// Variables for expression evaluation.
+ /// Variables for expression evaluation.
///
- protected override void SetTargetValue(object target, object value, IDictionary variables)
+ protected override void SetTargetValue(object target, object value, IDictionary variables)
{
this.TargetExpression.SetValue(target, variables, value);
}
diff --git a/src/Spring/Spring.Core/Expressions/BaseNode.cs b/src/Spring/Spring.Core/Expressions/BaseNode.cs
index 17888ad6..66951740 100644
--- a/src/Spring/Spring.Core/Expressions/BaseNode.cs
+++ b/src/Spring/Spring.Core/Expressions/BaseNode.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Spring.Expressions
@@ -99,7 +100,7 @@ namespace Spring.Expressions
///
/// Gets/Sets global variables of the current evaluation
///
- public IDictionary Variables;
+ public IDictionary Variables;
///
/// Gets/Sets local variables of the current evaluation
///
@@ -110,7 +111,7 @@ namespace Spring.Expressions
///
/// The root context for this evaluation
/// dictionary of global variables used during this evaluation
- public EvaluationContext(object rootContext, IDictionary globalVariables)
+ public EvaluationContext(object rootContext, IDictionary globalVariables)
{
this.RootContext = rootContext;
this.ThisContext = rootContext;
@@ -175,7 +176,7 @@ namespace Spring.Expressions
/// Object to evaluate node against.
/// Expression variables map.
/// Node's value.
- public object GetValue(object context, IDictionary variables)
+ public object GetValue(object context, IDictionary variables)
{
EvaluationContext evalContext = new EvaluationContext(context, variables);
return Get(context, evalContext);
@@ -211,7 +212,7 @@ namespace Spring.Expressions
/// Object to evaluate node against.
/// Expression variables map.
/// New value for this node.
- public void SetValue(object context, IDictionary variables, object newValue)
+ public void SetValue(object context, IDictionary variables, object newValue)
{
EvaluationContext evalContext = new EvaluationContext(context, variables);
Set(context, evalContext, newValue);
diff --git a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
index a80e8db7..332b273a 100644
--- a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
+++ b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
@@ -189,7 +190,7 @@ namespace Spring.Expressions
private static ConstructorInfo[] GetCandidateConstructors(Type type, int argCount)
{
ConstructorInfo[] ctors = type.GetConstructors(BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
- ArrayList matches = new ArrayList();
+ List matches = new List();
foreach (ConstructorInfo ctor in ctors)
{
@@ -208,7 +209,7 @@ namespace Spring.Expressions
}
}
- return (ConstructorInfo[]) matches.ToArray(typeof(ConstructorInfo));
+ return matches.ToArray();
}
}
diff --git a/src/Spring/Spring.Core/Expressions/Expression.cs b/src/Spring/Spring.Core/Expressions/Expression.cs
index 4f42f3f6..da201685 100644
--- a/src/Spring/Spring.Core/Expressions/Expression.cs
+++ b/src/Spring/Spring.Core/Expressions/Expression.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
@@ -324,7 +325,7 @@ namespace Spring.Expressions
/// Context to evaluate expression against.
/// Expression variables map.
/// Value of the last node.
- internal PropertyInfo GetPropertyInfo( object context, IDictionary variables )
+ internal PropertyInfo GetPropertyInfo( object context, IDictionary variables )
{
if (this.getNumberOfChildren() > 0)
{
diff --git a/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs b/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs
index 97494cfa..c2e6cbaa 100644
--- a/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs
+++ b/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs
@@ -18,7 +18,7 @@
#endregion
-using System.Collections;
+using System.Collections.Generic;
namespace Spring.Expressions
{
@@ -34,7 +34,7 @@ namespace Spring.Expressions
/// Methods in this class parse expression on every invocation.
/// If you plan to reuse the same expression many times, you should prepare
/// the expression once using the static method,
- /// and then call to evaluate it.
+ /// and then call to evaluate it.
///
///
/// This can result in significant performance improvements as it avoids expression
@@ -65,7 +65,7 @@ namespace Spring.Expressions
/// Expression to evaluate.
/// Expression variables map.
/// Value of the last node in the expression.
- public static object GetValue(object root, string expression, IDictionary variables)
+ public static object GetValue(object root, string expression, IDictionary variables)
{
IExpression exp = Expression.Parse(expression);
return exp.GetValue(root, variables);
@@ -92,7 +92,7 @@ namespace Spring.Expressions
/// Expression to evaluate.
/// Expression variables map.
/// Value to set last node to.
- public static void SetValue(object root, string expression, IDictionary variables, object newValue)
+ public static void SetValue(object root, string expression, IDictionary variables, object newValue)
{
IExpression exp = Expression.Parse(expression);
exp.SetValue(root, variables, newValue);
diff --git a/src/Spring/Spring.Core/Expressions/IExpression.cs b/src/Spring/Spring.Core/Expressions/IExpression.cs
index 1d132fae..346baada 100644
--- a/src/Spring/Spring.Core/Expressions/IExpression.cs
+++ b/src/Spring/Spring.Core/Expressions/IExpression.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
namespace Spring.Expressions
@@ -49,7 +50,7 @@ namespace Spring.Expressions
/// Object to evaluate expression against.
/// Expression variables map.
/// Value of the expression.
- object GetValue(object context, IDictionary variables);
+ object GetValue(object context, IDictionary variables);
///
/// Sets expression value.
@@ -64,6 +65,6 @@ namespace Spring.Expressions
/// Object to evaluate expression against.
/// Expression variables map.
/// New value for the last node of the expression.
- void SetValue(object context, IDictionary variables, object newValue);
+ void SetValue(object context, IDictionary variables, object newValue);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Expressions/IndexerNode.cs b/src/Spring/Spring.Core/Expressions/IndexerNode.cs
index 365ca141..66570388 100644
--- a/src/Spring/Spring.Core/Expressions/IndexerNode.cs
+++ b/src/Spring/Spring.Core/Expressions/IndexerNode.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using Spring.Core;
@@ -184,7 +185,7 @@ namespace Spring.Expressions
/// Context to resolve property against.
/// Expression variables map.
/// PropertyInfo for this node.
- internal PropertyInfo GetPropertyInfo(object context, IDictionary variables)
+ internal PropertyInfo GetPropertyInfo(object context, IDictionary variables)
{
lock (this)
{
diff --git a/src/Spring/Spring.Core/Expressions/MethodNode.cs b/src/Spring/Spring.Core/Expressions/MethodNode.cs
index 64f9a774..e7f0d99b 100644
--- a/src/Spring/Spring.Core/Expressions/MethodNode.cs
+++ b/src/Spring/Spring.Core/Expressions/MethodNode.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using Spring.Expressions.Processors;
@@ -110,7 +111,9 @@ namespace Spring.Expressions
// user-defined collection processor?
if (localCollectionProcessor == null && evalContext.Variables != null)
{
- localCollectionProcessor = evalContext.Variables[methodName] as ICollectionProcessor;
+ object temp;
+ evalContext.Variables.TryGetValue(methodName, out temp);
+ localCollectionProcessor = temp as ICollectionProcessor;
}
}
@@ -120,7 +123,9 @@ namespace Spring.Expressions
// user-defined extension method processor?
if (methodCallProcessor == null && evalContext.Variables != null)
{
- methodCallProcessor = evalContext.Variables[methodName] as IMethodCallProcessor;
+ object temp;
+ evalContext.Variables.TryGetValue(methodName, out temp);
+ methodCallProcessor = temp as IMethodCallProcessor;
}
}
@@ -243,7 +248,7 @@ namespace Spring.Expressions
private static MethodInfo[] GetCandidateMethods(Type type, string methodName, BindingFlags bindingFlags, int argCount)
{
MethodInfo[] methods = type.GetMethods(bindingFlags | BindingFlags.FlattenHierarchy);
- ArrayList matches = new ArrayList();
+ List matches = new List();
foreach (MethodInfo method in methods)
{
@@ -265,7 +270,7 @@ namespace Spring.Expressions
}
}
- return (MethodInfo[])matches.ToArray(typeof(MethodInfo));
+ return matches.ToArray();
}
// used to calculate signature hash while caring for arg positions
diff --git a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
index c971e566..2ba27be7 100644
--- a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
+++ b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Runtime.Serialization;
using Spring.Expressions.Parser.antlr.collections;
@@ -76,7 +77,7 @@ namespace Spring.Expressions
{
if (args == null)
{
- ArrayList argList = new ArrayList();
+ List argList = new List();
namedArgs = new Hashtable();
AST node = this.getFirstChild();
@@ -85,7 +86,7 @@ namespace Spring.Expressions
{
if (node.getFirstChild() is LambdaExpressionNode)
{
- argList.Add(node.getFirstChild());
+ argList.Add((BaseNode) node.getFirstChild());
}
else if (node is NamedArgumentNode)
{
@@ -93,12 +94,12 @@ namespace Spring.Expressions
}
else
{
- argList.Add(node);
+ argList.Add((BaseNode) node);
}
node = node.getNextSibling();
}
- args = (BaseNode[]) argList.ToArray(typeof (BaseNode));
+ args = argList.ToArray();
}
}
}
diff --git a/src/Spring/Spring.Core/Expressions/Processors/OrderByProcessor.cs b/src/Spring/Spring.Core/Expressions/Processors/OrderByProcessor.cs
index 97174c44..70eee788 100644
--- a/src/Spring/Spring.Core/Expressions/Processors/OrderByProcessor.cs
+++ b/src/Spring/Spring.Core/Expressions/Processors/OrderByProcessor.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Spring.Util;
namespace Spring.Expressions.Processors
@@ -57,7 +58,7 @@ namespace Spring.Expressions.Processors
private class LambdaComparer : IComparer
{
- private readonly Hashtable _variables;
+ private readonly Dictionary _variables;
private readonly IExpression _fn;
public LambdaComparer(LambdaExpressionNode lambdaExpression)
@@ -73,7 +74,7 @@ namespace Spring.Expressions.Processors
functionNode.addChild(y);
_fn = functionNode;
- _variables = new Hashtable();
+ _variables = new Dictionary();
_variables.Add( "compare", lambdaExpression );
}
diff --git a/src/Spring/Spring.Core/Globalization/AbstractLocalizer.cs b/src/Spring/Spring.Core/Globalization/AbstractLocalizer.cs
index 85a7d864..68e83dff 100644
--- a/src/Spring/Spring.Core/Globalization/AbstractLocalizer.cs
+++ b/src/Spring/Spring.Core/Globalization/AbstractLocalizer.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Threading;
@@ -72,7 +73,7 @@ namespace Spring.Globalization
AssertUtils.ArgumentNotNull(target, "target");
AssertUtils.ArgumentNotNull(culture, "culture");
- IList resources = GetResources(target, messageSource, culture);
+ IList resources = GetResources(target, messageSource, culture);
foreach (Resource resource in resources)
{
resource.Target.SetValue(target, null, resource.Value);
@@ -97,9 +98,9 @@ namespace Spring.Globalization
/// instance to retrieve resources from.
/// Resource locale.
/// A list of resources to apply.
- private IList GetResources(object target, IMessageSource messageSource, CultureInfo culture)
+ private IList GetResources(object target, IMessageSource messageSource, CultureInfo culture)
{
- IList resources = resourceCache.GetResources(target, culture);
+ IList resources = resourceCache.GetResources(target, culture);
if (resources == null)
{
@@ -117,7 +118,7 @@ namespace Spring.Globalization
/// instance to retrieve resources from.
/// Resource locale.
/// A list of resources to apply.
- protected abstract IList LoadResources(object target, IMessageSource messageSource, CultureInfo culture);
+ protected abstract IList LoadResources(object target, IMessageSource messageSource, CultureInfo culture);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Globalization/AbstractResourceCache.cs b/src/Spring/Spring.Core/Globalization/AbstractResourceCache.cs
index 0f3aafe2..d448ee4c 100644
--- a/src/Spring/Spring.Core/Globalization/AbstractResourceCache.cs
+++ b/src/Spring/Spring.Core/Globalization/AbstractResourceCache.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
namespace Spring.Globalization
@@ -35,7 +36,7 @@ namespace Spring.Globalization
/// Target to get a list of resources for.
/// Resource culture.
/// A list of cached resources for the specified target object and culture.
- public IList GetResources(object target, CultureInfo culture)
+ public IList GetResources(object target, CultureInfo culture)
{
return GetResources(CreateCacheKey(target, culture));
}
@@ -47,7 +48,7 @@ namespace Spring.Globalization
/// Resource culture.
/// A list of resources to cache.
/// A list of cached resources for the specified target object and culture.
- public void PutResources(object target, CultureInfo culture, IList resources)
+ public void PutResources(object target, CultureInfo culture, IList resources)
{
PutResources(CreateCacheKey(target, culture), resources);
}
@@ -67,7 +68,7 @@ namespace Spring.Globalization
///
/// Cache key to use for lookup.
/// A list of cached resources for the specified target object and culture.
- protected abstract IList GetResources(string cacheKey);
+ protected abstract IList GetResources(string cacheKey);
///
/// Puts the list of resources in the cache.
@@ -75,7 +76,7 @@ namespace Spring.Globalization
/// Cache key to use for the specified resources.
/// A list of resources to cache.
/// A list of cached resources for the specified target object and culture.
- protected abstract void PutResources(string cacheKey, IList resources);
+ protected abstract void PutResources(string cacheKey, IList resources);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Globalization/IResourceCache.cs b/src/Spring/Spring.Core/Globalization/IResourceCache.cs
index 7d431c1e..07bbe70a 100644
--- a/src/Spring/Spring.Core/Globalization/IResourceCache.cs
+++ b/src/Spring/Spring.Core/Globalization/IResourceCache.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
namespace Spring.Globalization
@@ -35,7 +36,7 @@ namespace Spring.Globalization
/// Target to get a list of resources for.
/// Resource culture.
/// A list of cached resources for the specified target object and culture.
- IList GetResources(object target, CultureInfo culture);
+ IList GetResources(object target, CultureInfo culture);
///
/// Puts the list of resources in the cache.
@@ -44,6 +45,6 @@ namespace Spring.Globalization
/// Resource culture.
/// A list of resources to cache.
/// A list of cached resources for the specified target object and culture.
- void PutResources(object target, CultureInfo culture, IList resources);
+ void PutResources(object target, CultureInfo culture, IList resources);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Globalization/Localizers/ResourceSetLocalizer.cs b/src/Spring/Spring.Core/Globalization/Localizers/ResourceSetLocalizer.cs
index b67a5186..66385249 100644
--- a/src/Spring/Spring.Core/Globalization/Localizers/ResourceSetLocalizer.cs
+++ b/src/Spring/Spring.Core/Globalization/Localizers/ResourceSetLocalizer.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Resources;
using Common.Logging;
@@ -60,10 +61,9 @@ namespace Spring.Globalization.Localizers
/// instance to retrieve resources from.
/// Resource locale.
/// A list of resources to apply.
- protected override IList LoadResources(object target, IMessageSource messageSource, CultureInfo culture)
+ protected override IList LoadResources(object target, IMessageSource messageSource, CultureInfo culture)
{
- IList resources;
- resources = new ArrayList();
+ IList resources = new List();
if (messageSource is ResourceSetMessageSource)
{
diff --git a/src/Spring/Spring.Core/Globalization/NullResourceCache.cs b/src/Spring/Spring.Core/Globalization/NullResourceCache.cs
index 3c1b23bf..505646c8 100644
--- a/src/Spring/Spring.Core/Globalization/NullResourceCache.cs
+++ b/src/Spring/Spring.Core/Globalization/NullResourceCache.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
namespace Spring.Globalization
{
@@ -33,7 +34,7 @@ namespace Spring.Globalization
///
/// Cache key to use for lookup.
/// Always returns null.
- protected override IList GetResources(string cacheKey)
+ protected override IList GetResources(string cacheKey)
{
return null;
}
@@ -43,7 +44,7 @@ namespace Spring.Globalization
///
/// Cache key to use for the specified resources.
/// A list of resources to cache.
- protected override void PutResources(string cacheKey, IList resources)
+ protected override void PutResources(string cacheKey, IList resources)
{}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/Events/Support/EventRegistry.cs b/src/Spring/Spring.Core/Objects/Events/Support/EventRegistry.cs
index a3087afb..ff410cc1 100644
--- a/src/Spring/Spring.Core/Objects/Events/Support/EventRegistry.cs
+++ b/src/Spring/Spring.Core/Objects/Events/Support/EventRegistry.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
#endregion
@@ -35,21 +36,21 @@ namespace Spring.Objects.Events.Support
/// Griffin Caprio
public class EventRegistry : IEventRegistry
{
- private readonly IList _publishers;
+ private readonly IList _publishers;
///
/// Creates a new instance of the EventRegistry class.
///
public EventRegistry()
{
- _publishers = new ArrayList();
+ _publishers = new List();
}
///
/// The list of event publishers.
///
/// The list of event publishers.
- protected IList Publishers
+ protected IList Publishers
{
get { return _publishers; }
}
diff --git a/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs
index caf4f148..19e174ba 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs
@@ -20,13 +20,11 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Text;
+
using Spring.Collections;
-using Spring.Objects;
-using Spring.Objects.Factory;
-using Spring.Objects.Factory.Attributes;
using Spring.Objects.Factory.Config;
using Spring.Util;
@@ -114,7 +112,7 @@ namespace Spring.Objects.Factory.Attributes
{
if (!validatedObjectNames.Contains(objectName))
{
- ArrayList invalidProperties = new ArrayList();
+ List invalidProperties = new List();
foreach (PropertyInfo pi in pis)
{
@@ -126,7 +124,7 @@ namespace Spring.Objects.Factory.Attributes
if (invalidProperties.Count != 0)
{
throw new ObjectInitializationException(
- BuildExceptionMessage((string[]) invalidProperties.ToArray(typeof (string)), objectName));
+ BuildExceptionMessage(invalidProperties.ToArray(), objectName));
}
validatedObjectNames.Add(objectName);
}
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/CommandLineArgsVariableSource.cs b/src/Spring/Spring.Core/Objects/Factory/Config/CommandLineArgsVariableSource.cs
index 39df90a0..8065aa6c 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/CommandLineArgsVariableSource.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/CommandLineArgsVariableSource.cs
@@ -19,8 +19,7 @@
#endregion
using System;
-using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
namespace Spring.Objects.Factory.Config
{
@@ -39,7 +38,7 @@ namespace Spring.Objects.Factory.Config
private string valueSeparator = DEFAULT_VALUE_SEPARATOR;
private string[] commandLineArgs;
- protected IDictionary arguments;
+ protected IDictionary arguments;
private object objectMonitor = new object();
@@ -103,7 +102,7 @@ namespace Spring.Objects.Factory.Config
{
InitArguments();
}
- return arguments.Contains(name);
+ return arguments.ContainsKey(name);
}
}
@@ -124,7 +123,9 @@ namespace Spring.Objects.Factory.Config
{
InitArguments();
}
- return (string) this.arguments[name];
+ string retValue;
+ arguments.TryGetValue(name, out retValue);
+ return retValue;
}
}
@@ -133,7 +134,7 @@ namespace Spring.Objects.Factory.Config
///
protected virtual void InitArguments()
{
- this.arguments = CollectionsUtil.CreateCaseInsensitiveHashtable(commandLineArgs.Length);
+ this.arguments = new Dictionary(StringComparer.OrdinalIgnoreCase);
foreach (string arg in commandLineArgs)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ConnectionStringsVariableSource.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ConnectionStringsVariableSource.cs
index e8b6f20f..73deefd7 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/ConnectionStringsVariableSource.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/ConnectionStringsVariableSource.cs
@@ -19,9 +19,9 @@
#endregion
using System;
-using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
using System.Configuration;
+
using Spring.Util;
namespace Spring.Objects.Factory.Config
@@ -53,7 +53,7 @@ namespace Spring.Objects.Factory.Config
[Serializable]
public class ConnectionStringsVariableSource : IVariableSource
{
- private Hashtable variables;
+ private Dictionary variables;
///
@@ -68,7 +68,7 @@ namespace Spring.Objects.Factory.Config
{
InitVariables();
}
- return variables.Contains(name);
+ return variables.ContainsKey(name);
}
///
@@ -86,7 +86,9 @@ namespace Spring.Objects.Factory.Config
{
InitVariables();
}
- return (string) variables[name];
+ string retValue;
+ variables.TryGetValue(name, out retValue);
+ return retValue;
}
///
@@ -95,7 +97,7 @@ namespace Spring.Objects.Factory.Config
///
private void InitVariables()
{
- variables = CollectionsUtil.CreateCaseInsensitiveHashtable();
+ variables = new Dictionary(StringComparer.OrdinalIgnoreCase);
ConnectionStringSettingsCollection settings = ConfigurationManager.ConnectionStrings;
foreach (ConnectionStringSettings setting in settings)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ConstructorArgumentValues.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ConstructorArgumentValues.cs
index 6135da89..64f89f17 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/ConstructorArgumentValues.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/ConstructorArgumentValues.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using Spring.Collections;
using Spring.Util;
@@ -83,9 +84,9 @@ namespace Spring.Objects.Factory.Config
#region Fields
private CultureInfo enUSCultureInfo = new CultureInfo("en-US", false);
- private IDictionary _indexedArgumentValues = new Hashtable();
- private IList _genericArgumentValues = new LinkedList();
- private IDictionary _namedArgumentValues = new Hashtable();
+ private IDictionary _indexedArgumentValues = new Dictionary();
+ private List _genericArgumentValues = new List();
+ private IDictionary _namedArgumentValues = new Dictionary();
#endregion
@@ -100,7 +101,7 @@ namespace Spring.Objects.Factory.Config
/// s
/// as values.
///
- public virtual IDictionary IndexedArgumentValues
+ public virtual IDictionary IndexedArgumentValues
{
get { return _indexedArgumentValues; }
}
@@ -114,7 +115,7 @@ namespace Spring.Objects.Factory.Config
/// s
/// as values.
///
- public virtual IDictionary NamedArgumentValues
+ public virtual IDictionary NamedArgumentValues
{
get { return _namedArgumentValues; }
}
@@ -126,7 +127,7 @@ namespace Spring.Objects.Factory.Config
/// A of
/// s.
///
- public virtual IList GenericArgumentValues
+ public virtual IList GenericArgumentValues
{
get { return _genericArgumentValues; }
@@ -175,19 +176,19 @@ namespace Spring.Objects.Factory.Config
{
if (other != null)
{
- foreach (object o in other.GenericArgumentValues)
+ foreach (ValueHolder o in other.GenericArgumentValues)
{
GenericArgumentValues.Add(o);
}
- foreach (DictionaryEntry entry in other.IndexedArgumentValues)
+ foreach (KeyValuePair entry in other.IndexedArgumentValues)
{
- ValueHolder vh = entry.Value as ValueHolder;
+ ValueHolder vh = entry.Value;
if (vh != null)
{
- AddOrMergeIndexedArgumentValues( (int) entry.Key, vh.Copy());
+ AddOrMergeIndexedArgumentValues( entry.Key, vh.Copy());
}
}
- foreach (DictionaryEntry entry in other.NamedArgumentValues)
+ foreach (KeyValuePair entry in other.NamedArgumentValues)
{
AddOrMergeNamedArgumentValues(entry.Key, entry.Value);
//NamedArgumentValues.Add(entry.Key, entry.Value);
@@ -195,9 +196,9 @@ namespace Spring.Objects.Factory.Config
}
}
- private void AddOrMergeNamedArgumentValues(object key, object newValue)
+ private void AddOrMergeNamedArgumentValues(string key, object newValue)
{
- if (_namedArgumentValues.Contains(key) )
+ if (_namedArgumentValues.ContainsKey(key) )
{
_namedArgumentValues[key] = newValue;
} else
@@ -208,9 +209,9 @@ namespace Spring.Objects.Factory.Config
private void AddOrMergeIndexedArgumentValues(int key, ValueHolder newValue)
{
- ValueHolder currentValue = _indexedArgumentValues[key] as ValueHolder;
+ ValueHolder currentValue;
IMergable mergable = newValue.Value as IMergable;
- if (currentValue != null && mergable != null )
+ if (_indexedArgumentValues.TryGetValue(key, out currentValue) && mergable != null )
{
if (mergable.MergeEnabled)
{
@@ -277,8 +278,8 @@ namespace Spring.Objects.Factory.Config
///
public virtual ValueHolder GetIndexedArgumentValue(int index, Type requiredType)
{
- ValueHolder valueHolder = (ValueHolder) IndexedArgumentValues[index];
- if (valueHolder != null)
+ ValueHolder valueHolder;
+ if (IndexedArgumentValues.TryGetValue(index, out valueHolder))
{
if (valueHolder.Type == null
|| requiredType.FullName.Equals(valueHolder.Type)
@@ -326,7 +327,7 @@ namespace Spring.Objects.Factory.Config
///
public bool ContainsNamedArgument(string argument)
{
- return NamedArgumentValues.Contains(GetCanonicalNamedArgument(argument));
+ return NamedArgumentValues.ContainsKey(GetCanonicalNamedArgument(argument));
}
///
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/DictionaryVariableSource.cs b/src/Spring/Spring.Core/Objects/Factory/Config/DictionaryVariableSource.cs
index 20840002..bdda3904 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/DictionaryVariableSource.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/DictionaryVariableSource.cs
@@ -20,7 +20,7 @@
using System;
using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
namespace Spring.Objects.Factory.Config
{
@@ -28,9 +28,9 @@ namespace Spring.Objects.Factory.Config
/// A very simple, hashtable-based implementation of
///
/// Erich Eichinger
- public class DictionaryVariableSource : IVariableSource, IEnumerable
+ public class DictionaryVariableSource : IVariableSource, IEnumerable>
{
- private readonly Hashtable variables;
+ private readonly Dictionary variables;
///
/// Creates a new, empty variable source
@@ -95,11 +95,11 @@ namespace Spring.Objects.Factory.Config
{
if (ignoreCase)
{
- variables = CollectionsUtil.CreateCaseInsensitiveHashtable();
+ variables = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
else
{
- variables = new Hashtable();
+ variables = new Dictionary();
}
if (dictionary != null)
@@ -140,16 +140,22 @@ namespace Spring.Objects.Factory.Config
///
public string ResolveVariable(string name)
{
- if (!variables.ContainsKey(name))
+ string value;
+ if (!variables.TryGetValue(name, out value))
{
throw new ArgumentException(string.Format("variable '{0}' cannot be resolved", name));
}
- return (string)variables[name];
+ return value;
+ }
+
+ IEnumerator> IEnumerable>.GetEnumerator()
+ {
+ return variables.GetEnumerator();
}
public IEnumerator GetEnumerator()
{
- return (variables as IEnumerable).GetEnumerator() ;
+ return variables.GetEnumerator();
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/EventValues.cs b/src/Spring/Spring.Core/Objects/Factory/Config/EventValues.cs
index 4c733e65..7d7107b1 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/EventValues.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/EventValues.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
#endregion
@@ -38,8 +39,7 @@ namespace Spring.Objects.Factory.Config
///
/// The empty array of s.
///
- private static readonly IEventHandlerValue [] EmptyHandlers
- = new IEventHandlerValue [] {};
+ private static readonly IEventHandlerValue [] EmptyHandlers = new IEventHandlerValue [] {};
#endregion
#region Constructor (s) / Destructor
@@ -69,7 +69,7 @@ namespace Spring.Objects.Factory.Config
/// of
/// s.
///
- protected IDictionary EventHandlers
+ protected IDictionary> EventHandlers
{
get
{
@@ -81,7 +81,7 @@ namespace Spring.Objects.Factory.Config
/// Gets the of events
/// that have handlers associated with them.
///
- public ICollection Events
+ public ICollection Events
{
get
{
@@ -94,13 +94,16 @@ namespace Spring.Objects.Factory.Config
/// s for the supplied
/// event name.
///
- public ICollection this [string eventName]
+ public ICollection this [string eventName]
{
- get
+ get
{
- return EventHandlers.Contains (eventName) ?
- EventHandlers [eventName] as ICollection :
- EventValues.EmptyHandlers;
+ IList handlers;
+ if (!EventHandlers.TryGetValue(eventName, out handlers))
+ {
+ handlers = EventValues.EmptyHandlers;
+ }
+ return handlers;
}
}
#endregion
@@ -131,12 +134,13 @@ namespace Spring.Objects.Factory.Config
/// Adds the supplied handler to the collection of event handlers.
///
/// The handler to be added.
- public void AddHandler (IEventHandlerValue handler)
+ public void AddHandler (IEventHandlerValue handler)
{
- IList handlers = EventHandlers [handler.EventName] as IList;
- if (handlers == null)
+ IList handlers;
+
+ if (!EventHandlers.TryGetValue(handler.EventName, out handlers))
{
- handlers = new ArrayList ();
+ handlers = new List();
EventHandlers [handler.EventName] = handlers;
}
handlers.Add (handler);
@@ -144,7 +148,7 @@ namespace Spring.Objects.Factory.Config
#endregion
#region Fields
- private IDictionary _eventHandlers = new Hashtable();
+ private IDictionary> _eventHandlers = new Dictionary>();
#endregion
}
}
diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs
index d6ec6f27..1b8a4b81 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs
@@ -21,7 +21,8 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using Spring.Collections;
@@ -124,40 +125,40 @@ namespace Spring.Objects.Factory.Config
}
}
}
- }
-
- ///
- /// Visits the indexed constructor argument values, replacing string values using the
- /// specified IVariableSource.
- ///
- /// The indexed argument values.
- protected virtual void VisitIndexedArgumentValues(IDictionary ias)
+ }
+
+ ///
+ /// Visits the indexed constructor argument values, replacing string values using the
+ /// specified IVariableSource.
+ ///
+ /// The indexed argument values.
+ protected virtual void VisitIndexedArgumentValues(IDictionary ias)
{
foreach (ConstructorArgumentValues.ValueHolder valueHolder in ias.Values)
{
ConfigureConstructorArgument(valueHolder);
}
- }
-
- ///
- /// Visits the named constructor argument values, replacing string values using the
- /// specified IVariableSource.
- ///
- /// The named argument values.
- protected virtual void VisitNamedArgumentValues(IDictionary nav)
+ }
+
+ ///
+ /// Visits the named constructor argument values, replacing string values using the
+ /// specified IVariableSource.
+ ///
+ /// The named argument values.
+ protected virtual void VisitNamedArgumentValues(IDictionary nav)
{
foreach (ConstructorArgumentValues.ValueHolder valueHolder in nav.Values)
{
ConfigureConstructorArgument(valueHolder);
}
- }
-
- ///
- /// Visits the generic constructor argument values, replacing string values using
- /// the specified IVariableSource.
- ///
- /// The genreic argument values.
- protected virtual void VisitGenericArgumentValues(IList gav)
+ }
+
+ ///
+ /// Visits the generic constructor argument values, replacing string values using
+ /// the specified IVariableSource.
+ ///
+ /// The genreic argument values.
+ protected virtual void VisitGenericArgumentValues(ICollection gav)
{
foreach (ConstructorArgumentValues.ValueHolder valueHolder in gav)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs
index 2911d715..9866b06b 100644
--- a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
#endregion
@@ -248,7 +249,7 @@ namespace Spring.Objects.Factory
///
/// If the objects could not be created.
///
- IDictionary GetObjectsOfType(Type type);
+ IDictionary GetObjectsOfType(Type type);
///
/// Return the object instances that match the given object
@@ -277,7 +278,7 @@ namespace Spring.Objects.Factory
///
/// If the objects could not be created.
///
- IDictionary GetObjectsOfType();
+ IDictionary GetObjectsOfType();
///
/// Return the object instances that match the given object
@@ -305,35 +306,35 @@ namespace Spring.Objects.Factory
///
/// If the objects could not be created.
///
- IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects);
+ IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects);
- ///
- /// Return the object instances that match the given object
- /// (including subclasses), judging from either object
- /// definitions or the value of
- /// in the case of
- /// s.
- ///
- ///
- /// The (class or interface) to match.
- ///
- ///
- /// Whether to include prototype objects too or just singletons (also applies to
- /// s).
- ///
- ///
- /// Whether to include s too
- /// or just normal objects.
- ///
- ///
- /// A of the matching objects,
- /// containing the object names as keys and the corresponding object instances
- /// as values.
- ///
- ///
- /// If the objects could not be created.
- ///
- IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects);
+ ///
+ /// Return the object instances that match the given object
+ /// (including subclasses), judging from either object
+ /// definitions or the value of
+ /// in the case of
+ /// s.
+ ///
+ ///
+ /// The (class or interface) to match.
+ ///
+ ///
+ /// Whether to include prototype objects too or just singletons (also applies to
+ /// s).
+ ///
+ ///
+ /// Whether to include s too
+ /// or just normal objects.
+ ///
+ ///
+ /// A of the matching objects,
+ /// containing the object names as keys and the corresponding object instances
+ /// as values.
+ ///
+ ///
+ /// If the objects could not be created.
+ ///
+ IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects);
///
/// Return an instance (possibly shared or independent) of the given object name.
diff --git a/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs b/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs
index e38561d7..c94455d9 100644
--- a/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs
@@ -21,9 +21,8 @@
#region Imports
using System;
-using System.Collections;
-using Spring.Collections;
-using Spring.Core;
+using System.Collections.Generic;
+
using Spring.Util;
#endregion
@@ -164,7 +163,7 @@ namespace Spring.Objects.Factory
IListableObjectFactory factory, Type type,
bool includePrototypes, bool includeFactoryObjects)
{
- ArrayList result = new ArrayList();
+ List result = new List();
result.AddRange(factory.GetObjectNamesForType(type, includePrototypes, includeFactoryObjects));
IListableObjectFactory pof = GetParentListableObjectFactoryIfAny(factory);
if (pof != null)
@@ -179,7 +178,7 @@ namespace Spring.Objects.Factory
}
}
}
- return (string[])result.ToArray(typeof(string));
+ return result.ToArray();
}
///
@@ -213,7 +212,7 @@ namespace Spring.Objects.Factory
public static string[] ObjectNamesForTypeIncludingAncestors(
IListableObjectFactory factory, Type type)
{
- ArrayList result = new ArrayList();
+ List result = new List();
result.AddRange(factory.GetObjectNamesForType(type));
IListableObjectFactory pof = GetParentListableObjectFactoryIfAny(factory);
if (pof != null)
@@ -228,7 +227,7 @@ namespace Spring.Objects.Factory
}
}
}
- return (string[])result.ToArray(typeof(string));
+ return result.ToArray();
}
///
@@ -259,12 +258,12 @@ namespace Spring.Objects.Factory
/// The of object instances, or an
/// empty if none.
///
- public static IDictionary ObjectsOfTypeIncludingAncestors(
+ public static IDictionary ObjectsOfTypeIncludingAncestors(
IListableObjectFactory factory, Type type,
bool includePrototypes, bool includeFactoryObjects)
{
- Hashtable result = new Hashtable();
- foreach (DictionaryEntry entry in
+ Dictionary result = new Dictionary();
+ foreach (KeyValuePair entry in
factory.GetObjectsOfType(type, includePrototypes, includeFactoryObjects))
{
result.Add(entry.Key, entry.Value);
@@ -273,7 +272,7 @@ namespace Spring.Objects.Factory
if (pof != null)
{
IHierarchicalObjectFactory hof = (IHierarchicalObjectFactory)factory;
- IDictionary parentResult = ObjectsOfTypeIncludingAncestors(pof, type, includePrototypes, includeFactoryObjects);
+ IDictionary parentResult = ObjectsOfTypeIncludingAncestors(pof, type, includePrototypes, includeFactoryObjects);
foreach (string objectName in parentResult.Keys)
{
if (!result.ContainsKey(objectName) && !hof.ContainsLocalObject(objectName))
@@ -319,7 +318,7 @@ namespace Spring.Objects.Factory
IListableObjectFactory factory, Type type,
bool includePrototypes, bool includeFactoryObjects)
{
- IDictionary objectsOfType = ObjectsOfTypeIncludingAncestors(factory, type, includePrototypes, includeFactoryObjects);
+ IDictionary objectsOfType = ObjectsOfTypeIncludingAncestors(factory, type, includePrototypes, includeFactoryObjects);
return GrabTheOnlyObject(objectsOfType, type);
}
@@ -355,7 +354,7 @@ namespace Spring.Objects.Factory
public static object ObjectOfType(IListableObjectFactory factory, Type type,
bool includePrototypes, bool includeFactoryObjects)
{
- IDictionary objectsOfType = factory.GetObjectsOfType(type, includePrototypes, includeFactoryObjects);
+ IDictionary objectsOfType = factory.GetObjectsOfType(type, includePrototypes, includeFactoryObjects);
return GrabTheOnlyObject(objectsOfType, type);
}
@@ -464,7 +463,7 @@ namespace Spring.Objects.Factory
return null;
}
- private static object GrabTheOnlyObject(IDictionary objectsOfType, Type type)
+ private static object GrabTheOnlyObject(IDictionary objectsOfType, Type type)
{
if (objectsOfType.Count == 1)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs
index 764c9860..25803c29 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs
@@ -22,17 +22,14 @@
using System;
using System.Collections;
-using System.Collections.Specialized;
+using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
-using System.Runtime.Remoting;
+
using Common.Logging;
+
using Spring.Collections;
-using Spring.Core;
-using Spring.Core.TypeConversion;
using Spring.Core.TypeResolution;
-using Spring.Expressions;
-using Spring.Objects;
using Spring.Objects.Factory.Config;
using Spring.Util;
@@ -701,7 +698,7 @@ namespace Spring.Objects.Factory.Support
{
// look for a matching type
Type requiredType = wrapper.GetPropertyType(propertyName);
- IDictionary matchingObjects = FindMatchingObjects(requiredType);
+ IDictionary matchingObjects = FindMatchingObjects(requiredType);
if (matchingObjects != null && matchingObjects.Count == 1)
{
properties.Add(propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Values));
@@ -1202,21 +1199,21 @@ namespace Spring.Objects.Factory.Support
{
lock (filteredPropertyDescriptorsCache)
{
- PropertyInfo[] filtered = (PropertyInfo[])filteredPropertyDescriptorsCache[wrapper.WrappedType];
- if (filtered == null)
+ PropertyInfo[] filtered;
+ if (!filteredPropertyDescriptorsCache.TryGetValue(wrapper.WrappedType, out filtered))
{
- ArrayList list = new ArrayList(wrapper.GetPropertyInfos());
+ List list = new List(wrapper.GetPropertyInfos());
for (int i = list.Count - 1; i >= 0; i--)
{
- PropertyInfo pi = (PropertyInfo)list[i];
+ PropertyInfo pi = list[i];
if (IsExcludedFromDependencyCheck(pi))
{
list.RemoveAt(i);
}
}
- filtered = (PropertyInfo[])list.ToArray(typeof(PropertyInfo));
+ filtered = list.ToArray();
filteredPropertyDescriptorsCache.Add(wrapper.WrappedType, filtered);
}
return filtered;
@@ -1747,7 +1744,7 @@ namespace Spring.Objects.Factory.Support
///
///
///
- /// The of the objects to look up.
+ /// The of the objects to look up.
///
///
/// An of object names and object
@@ -1757,7 +1754,7 @@ namespace Spring.Objects.Factory.Support
///
/// In case of errors.
///
- protected abstract IDictionary FindMatchingObjects(Type requiredType);
+ protected abstract IDictionary FindMatchingObjects(Type requiredType);
///
/// Return the names of the objects that depend on the given object.
@@ -2083,7 +2080,7 @@ namespace Spring.Objects.Factory.Support
///
/// Cache of filtered PropertyInfos: object Type -> PropertyInfo array
///
- private IDictionary filteredPropertyDescriptorsCache = new Hashtable();
+ private IDictionary filteredPropertyDescriptorsCache = new Dictionary();
///
/// Dependency interfaces to ignore on dependency check and autowire, as Set of
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs
index ee48e420..6defe1cd 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
@@ -740,12 +741,12 @@ namespace Spring.Objects.Factory.Support
}
if (ArrayUtils.HasLength(other.DependsOn))
{
- ArrayList deps = new ArrayList(other.DependsOn);
+ List deps = new List(other.DependsOn);
if (ArrayUtils.HasLength(DependsOn))
{
deps.AddRange(DependsOn);
}
- DependsOn = (string[]) deps.ToArray(typeof(string));
+ DependsOn = deps.ToArray();
}
AutowireMode = other.AutowireMode;
ResourceDescription = other.ResourceDescription;
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs
index ad19745b..7cd5c38b 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs
@@ -22,18 +22,21 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
-using System.Runtime.Serialization;
+
using Common.Logging;
using Spring.Collections;
+using Spring.Collections.Generic;
using Spring.Core;
using Spring.Core.TypeConversion;
using Spring.Objects.Factory.Config;
using Spring.Threading;
using Spring.Util;
using System.Threading;
+using System.Linq;
#endregion
@@ -140,7 +143,7 @@ namespace Spring.Objects.Factory.Support
///
/// Cache of singleton objects created by s: FactoryObject name -> product
///
- private readonly Hashtable factoryObjectProductCache = new Hashtable();
+ private readonly Dictionary factoryObjectProductCache = new Dictionary();
#region Constructor (s) / Destructor
@@ -904,7 +907,7 @@ namespace Spring.Objects.Factory.Support
if (rod == null)
{
- resultInstance = factoryObjectProductCache[canonicalName];
+ factoryObjectProductCache.TryGetValue(canonicalName, out resultInstance);
}
if (resultInstance == null)
@@ -926,10 +929,9 @@ namespace Spring.Objects.Factory.Support
if (factory.IsSingleton && ContainsSingleton(canonicalName))
{
- lock (factoryObjectProductCache.SyncRoot)
+ lock (factoryObjectProductCache)
{
- resultInstance = factoryObjectProductCache[canonicalName];
- if (resultInstance == null)
+ if (!factoryObjectProductCache.TryGetValue(canonicalName, out resultInstance))
{
resultInstance = GetObjectFromFactoryObject(factory, canonicalName, rod);
if (resultInstance != null)
@@ -1213,7 +1215,7 @@ namespace Spring.Objects.Factory.Support
{
lock (singletonCache)
{
- ArrayList matches = new ArrayList();
+ List matches = new List();
foreach (string name in singletonCache.Keys)
{
object singletonObject = singletonCache[name];
@@ -1223,7 +1225,7 @@ namespace Spring.Objects.Factory.Support
matches.Add(name);
}
}
- return (string[])matches.ToArray(typeof(string));
+ return matches.ToArray();
}
}
@@ -1450,8 +1452,8 @@ namespace Spring.Objects.Factory.Support
{
lock (singletonCache)
{
- ICollection keys = singletonCache.Keys;
- return (string[])new ArrayList(keys).ToArray(typeof(string));
+ IEnumerable keys = singletonCache.Keys.Cast();
+ return new List(keys).ToArray();
}
}
@@ -1613,9 +1615,9 @@ namespace Spring.Objects.Factory.Support
private bool hasDestructionAwareBeanPostProcessors;
private bool caseSensitive;
- private IDictionary aliasMap;
- private IDictionary singletonCache;
- private IDictionary singletonLocks;
+ private OrderedDictionary aliasMap;
+ private OrderedDictionary singletonCache;
+ private OrderedDictionary singletonLocks;
///
/// Set of registered singletons, containing the bean names in registration order
@@ -1821,18 +1823,18 @@ namespace Spring.Objects.Factory.Support
if (isInSingletonCache || ContainsObjectDefinition(objectName))
{
// if found, gather aliases...
- ArrayList matches = new ArrayList();
+ List matches = new List();
lock (aliasMap)
{
foreach (DictionaryEntry aliasEntry in aliasMap)
{
if (0 == string.Compare((string)aliasEntry.Value, objectName, !this.IsCaseSensitive))
{
- matches.Add(aliasEntry.Key);
+ matches.Add((string) aliasEntry.Key);
}
}
}
- return (string[])matches.ToArray(typeof(string));
+ return matches.ToArray();
}
// not found, so check parent...
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs
index 3ad46d96..9f8d4634 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Spring.Collections;
using Spring.Core;
@@ -356,7 +357,7 @@ namespace Spring.Objects.Factory.Support
/// the filtered list. Is never null
public static PropertyInfo[] GetUnsatisfiedDependencies(PropertyInfo[] propertyInfos, IPropertyValues properties, DependencyCheckingMode dependencyCheck)
{
- ArrayList unsatisfiedDependenciesList = new ArrayList();
+ List unsatisfiedDependenciesList = new List();
foreach (PropertyInfo property in propertyInfos)
{
if (property.CanWrite && properties.GetPropertyValue(property.Name) == null)
@@ -370,7 +371,7 @@ namespace Spring.Objects.Factory.Support
}
}
}
- return (PropertyInfo[])unsatisfiedDependenciesList.ToArray(typeof(PropertyInfo));
+ return unsatisfiedDependenciesList.ToArray();
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs
index 2d7ba754..c862ce91 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Common.Logging;
@@ -540,7 +541,7 @@ namespace Spring.Objects.Factory.Support
// ObjectDefinitionValueResolver valueResolver = new ObjectDefinitionValueResolver(objectFactory);
int minNrOfArgs = cargs.ArgumentCount;
- foreach (DictionaryEntry entry in cargs.IndexedArgumentValues)
+ foreach (KeyValuePair entry in cargs.IndexedArgumentValues)
{
int index = Convert.ToInt32(entry.Key);
if (index < 0)
@@ -552,8 +553,7 @@ namespace Spring.Objects.Factory.Support
{
minNrOfArgs = index + 1;
}
- ConstructorArgumentValues.ValueHolder valueHolder =
- (ConstructorArgumentValues.ValueHolder)entry.Value;
+ ConstructorArgumentValues.ValueHolder valueHolder = entry.Value;
string argName = "constructor argument with index " + index;
object resolvedValue =
valueResolver.ResolveValueIfNecessary(objectName, definition, argName, valueHolder.Value);
@@ -575,9 +575,9 @@ namespace Spring.Objects.Factory.Support
AssemblyQualifiedName
: null);
}
- foreach (DictionaryEntry namedArgumentEntry in definition.ConstructorArgumentValues.NamedArgumentValues)
+ foreach (KeyValuePair namedArgumentEntry in definition.ConstructorArgumentValues.NamedArgumentValues)
{
- string argumentName = (string)namedArgumentEntry.Key;
+ string argumentName = namedArgumentEntry.Key;
string syntheticArgumentName = "constructor argument with name " + argumentName;
ConstructorArgumentValues.ValueHolder valueHolder =
(ConstructorArgumentValues.ValueHolder)namedArgumentEntry.Value;
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs
index 522ced09..20eca0d3 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs
@@ -22,14 +22,14 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
-using System.Reflection;
+
using Common.Logging;
-using Spring.Collections;
+using Spring.Collections.Generic;
using Spring.Core;
using Spring.Core.TypeConversion;
-using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Util;
@@ -112,13 +112,14 @@ namespace Spring.Objects.Factory.Support
public DefaultListableObjectFactory(bool caseSensitive, IObjectFactory parentFactory)
: base(caseSensitive, parentFactory)
{
+ AllowObjectDefinitionOverriding = true;
if (caseSensitive)
{
- objectDefinitionMap = new Hashtable();
+ objectDefinitionMap = new Dictionary();
}
else
{
- objectDefinitionMap = new CaseInsensitiveHashtable(); //CollectionsUtil.CreateCaseInsensitiveHashtable();
+ objectDefinitionMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
}
@@ -146,11 +147,7 @@ namespace Spring.Objects.Factory.Support
/// is the registration of an object definition
/// under the same name as an existing object definition is allowed.
///
- public bool AllowObjectDefinitionOverriding
- {
- get { return allowObjectDefinitionOverriding; }
- set { allowObjectDefinitionOverriding = value; }
- }
+ public bool AllowObjectDefinitionOverriding { get; set; }
///
@@ -185,7 +182,7 @@ namespace Spring.Objects.Factory.Support
///
///
///
- /// The type of the objects to look up.
+ /// The type of the objects to look up.
///
///
/// An of object names and object
@@ -195,7 +192,7 @@ namespace Spring.Objects.Factory.Support
///
/// In case of errors.
///
- protected override IDictionary FindMatchingObjects(Type requiredType)
+ protected override IDictionary FindMatchingObjects(Type requiredType)
{
return ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(
this, requiredType, true, true);
@@ -222,7 +219,7 @@ namespace Spring.Objects.Factory.Support
///
protected override string[] GetDependingObjectNames(string objectName)
{
- ArrayList dependingObjectNames = new ArrayList();
+ List dependingObjectNames = new List();
string[] allObjectDefinitionNames = GetObjectDefinitionNames();
foreach (string name in allObjectDefinitionNames)
{
@@ -232,7 +229,7 @@ namespace Spring.Objects.Factory.Support
= GetMergedObjectDefinition(name, false);
if (rod.DependsOn != null)
{
- IList dependsOn = new ArrayList(rod.DependsOn);
+ HashSet dependsOn = new HashSet(rod.DependsOn);
if (dependsOn.Contains(objectName))
{
#region Instrumentation
@@ -252,7 +249,7 @@ namespace Spring.Objects.Factory.Support
}
}
}
- return (string[])dependingObjectNames.ToArray(typeof(string));
+ return dependingObjectNames.ToArray();
}
///
@@ -310,21 +307,15 @@ namespace Spring.Objects.Factory.Support
///
private readonly ILog log = LogManager.GetLogger(typeof(DefaultListableObjectFactory));
- ///
- /// Whether to allow re-registration of a different definition with the
- /// same name.
- ///
- private bool allowObjectDefinitionOverriding = true;
-
///
/// The mapping of object definition objects, keyed by object name.
///
- private readonly IDictionary objectDefinitionMap;
+ private readonly IDictionary objectDefinitionMap;
///
/// List of object definition names, in registration order.
///
- private readonly IList objectDefinitionNames = new ArrayList();
+ private readonly List objectDefinitionNames = new List();
///
/// Resolver to use for checking if an object definition is an autowire candidate
@@ -366,7 +357,7 @@ namespace Spring.Objects.Factory.Support
///
public override bool ContainsObjectDefinition(string name)
{
- return objectDefinitionMap.Contains(name);
+ return objectDefinitionMap.ContainsKey(name);
}
///
@@ -400,8 +391,8 @@ namespace Spring.Objects.Factory.Support
ex);
}
}
- object oldObjectDefinition = objectDefinitionMap[name];
- if (oldObjectDefinition != null)
+ IObjectDefinition oldObjectDefinition;
+ if (objectDefinitionMap.TryGetValue(name, out oldObjectDefinition))
{
if (!AllowObjectDefinitionOverriding)
{
@@ -460,7 +451,7 @@ namespace Spring.Objects.Factory.Support
int definitionCount = objectDefinitionNames.Count;
for (int i = 0; i < definitionCount; i++)
{
- string name = (string)objectDefinitionNames[i];
+ string name = objectDefinitionNames[i];
if (!ContainsSingleton(name) && ContainsObjectDefinition(name))
{
RootObjectDefinition definition
@@ -585,8 +576,8 @@ namespace Spring.Objects.Factory.Support
}
name = TransformedObjectName(name);
- IObjectDefinition definition = (IObjectDefinition)objectDefinitionMap[name];
- if (definition == null)
+ IObjectDefinition definition;
+ if (!objectDefinitionMap.TryGetValue(name, out definition))
{
if (!includeAncestors || ParentObjectFactory == null)
{
@@ -615,7 +606,7 @@ namespace Spring.Objects.Factory.Support
///
public string[] GetObjectDefinitionNames()
{
- return (string[])((ArrayList)objectDefinitionNames).ToArray(typeof(string));
+ return objectDefinitionNames.ToArray();
}
///
@@ -633,7 +624,7 @@ namespace Spring.Objects.Factory.Support
///
public string[] GetObjectDefinitionNames(Type type)
{
- ArrayList matches = new ArrayList();
+ List matches = new List();
foreach (string name in objectDefinitionNames)
{
if (IsObjectDefinitionTypeMatch(name, type))
@@ -641,7 +632,7 @@ namespace Spring.Objects.Factory.Support
matches.Add(name);
}
}
- return (string[])matches.ToArray(typeof(string));
+ return matches.ToArray();
}
///
@@ -711,11 +702,10 @@ namespace Spring.Objects.Factory.Support
/// are defined.
///
///
- public string[] GetObjectNamesForType(
- Type type, bool includePrototypes, bool includeFactoryObjects)
+ public string[] GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
- IList objectNames = DoGetObjectNamesForType(type, includePrototypes, includeFactoryObjects);
- return (string[])ArrayList.Adapter(objectNames).ToArray(typeof(string));
+ List objectNames = DoGetObjectNamesForType(type, includePrototypes, includeFactoryObjects);
+ return objectNames.ToArray();
}
///
@@ -777,7 +767,7 @@ namespace Spring.Objects.Factory.Support
/// If the objects could not be created.
///
///
- public IDictionary GetObjectsOfType(Type type)
+ public IDictionary GetObjectsOfType(Type type)
{
return GetObjectsOfType(type, true, true);
}
@@ -809,9 +799,11 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType()
+ public IDictionary GetObjectsOfType()
{
- return GetObjectsOfType(typeof (T));
+ Dictionary result = new Dictionary();
+ DoGetObjectsOfType(typeof (T), true, true, result);
+ return result;
}
///
@@ -838,21 +830,26 @@ namespace Spring.Objects.Factory.Support
/// If any of the objects could not be created.
///
///
- public IDictionary GetObjectsOfType(
- Type type, bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
- IDictionary result = new Hashtable();
- IList objectNames = DoGetObjectNamesForType(type, includePrototypes, includeFactoryObjects);
+ Dictionary result = new Dictionary();
+ DoGetObjectsOfType(type, includePrototypes, includeFactoryObjects, result);
+ return result;
+ }
+
+ private void DoGetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects, IDictionary resultCollector)
+ {
+ IList objectNames = DoGetObjectNamesForType(type, includePrototypes, includeFactoryObjects);
foreach (string objectName in objectNames)
{
try
{
- result.Add(objectName, GetObject(objectName));
+ resultCollector.Add(objectName, GetObject(objectName));
}
catch (ObjectCreationException ex)
{
if (ex.InnerException != null
- && ex.GetBaseException().GetType().Equals(typeof(ObjectCurrentlyInCreationException)))
+ && ex.GetBaseException().GetType().Equals(typeof (ObjectCurrentlyInCreationException)))
{
// ignoring this is ok... it indicates a circular reference when autowiring
// constructors; we want to find matches other than the currently
@@ -860,9 +857,9 @@ namespace Spring.Objects.Factory.Support
if (log.IsDebugEnabled)
{
log.Debug(string.Format(
- CultureInfo.InvariantCulture,
- "Ignoring match to currently created object '{0}'.",
- objectName), ex);
+ CultureInfo.InvariantCulture,
+ "Ignoring match to currently created object '{0}'.",
+ objectName), ex);
}
}
else
@@ -871,7 +868,6 @@ namespace Spring.Objects.Factory.Support
}
}
}
- return result;
}
///
@@ -885,12 +881,12 @@ namespace Spring.Objects.Factory.Support
/// The (class or interface) to match.
///
///
- /// Whether to include prototype objects too or just singletons (also applies to
- /// s).
+ /// Whether to include prototype objects too or just singletons (also applies to
+ /// s).
///
///
- /// Whether to include s too
- /// or just normal objects.
+ /// Whether to include s too
+ /// or just normal objects.
///
///
/// A of the matching objects,
@@ -900,9 +896,11 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
{
- return GetObjectsOfType(typeof (T), includePrototypes, includeFactoryObjects);
+ Dictionary result = new Dictionary();
+ DoGetObjectsOfType(typeof (T), includePrototypes, includeFactoryObjects, result);
+ return result;
}
///
@@ -974,9 +972,9 @@ namespace Spring.Objects.Factory.Support
/// If any of the objects could not be created.
///
///
- protected IList DoGetObjectNamesForType(Type type, bool includeNonSingletons, bool allowEagerInit)
+ protected List DoGetObjectNamesForType(Type type, bool includeNonSingletons, bool allowEagerInit)
{
- IList result = new ArrayList();
+ List result = new List();
string[] objectNames = GetObjectDefinitionNames();
foreach (string s in objectNames)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs
index 7cf022c6..e3a9a068 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs
@@ -20,7 +20,8 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections;
+using System.Collections.Generic;
using Spring.Objects.Factory.Config;
#endregion
@@ -392,11 +393,11 @@ namespace Spring.Objects.Factory.Support
objectDefinition.DependsOn = new string[] {objectName};
}
else
- {
- ArrayList arrayList = new ArrayList();
+ {
+ List arrayList = new List();
arrayList.AddRange(objectDefinition.DependsOn);
arrayList.AddRange(new string[]{ objectName});
- objectDefinition.DependsOn = (string[])arrayList.ToArray(typeof(string));
+ objectDefinition.DependsOn = arrayList.ToArray();
}
return this;
}
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs
index 3d2fbd48..114dc6d3 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionValueResolver.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Runtime.Remoting;
@@ -166,7 +167,7 @@ namespace Spring.Objects.Factory.Support
{
ExpressionHolder expHolder = (ExpressionHolder)argumentValue;
object context = null;
- IDictionary variables = null;
+ IDictionary variables = null;
if (expHolder.Properties != null)
{
@@ -180,9 +181,18 @@ namespace Spring.Objects.Factory.Support
? null
: ResolveValueIfNecessary(name, definition, "Variables",
variablesProperty.Value));
+ if (vars is IDictionary)
+ {
+ variables = (IDictionary)vars;
+ }
if (vars is IDictionary)
{
- variables = (IDictionary)vars;
+ IDictionary temp = (IDictionary) vars;
+ variables = new Dictionary(temp.Count);
+ foreach (DictionaryEntry entry in temp)
+ {
+ variables.Add((string) entry.Key, entry.Value);
+ }
}
else
{
@@ -190,7 +200,7 @@ namespace Spring.Objects.Factory.Support
}
}
- if (variables == null) variables = CollectionsUtil.CreateCaseInsensitiveHashtable();
+ if (variables == null) variables = new Dictionary(StringComparer.OrdinalIgnoreCase);
// add 'this' objectfactory reference to variables
variables.Add(Expression.ReservedVariableNames.CurrentObjectFactory, objectFactory);
@@ -199,8 +209,7 @@ namespace Spring.Objects.Factory.Support
else if (argumentValue is IManagedCollection)
{
resolvedValue =
- ((IManagedCollection)argumentValue).Resolve(name, definition, argumentName,
- new ManagedCollectionElementResolver(ResolveValueIfNecessary));
+ ((IManagedCollection)argumentValue).Resolve(name, definition, argumentName, ResolveValueIfNecessary);
}
else if (argumentValue is TypedStringValue)
{
diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs
index 98ead8fd..6342512f 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs
@@ -19,8 +19,8 @@
#region Imports
using System;
-using System.Collections;
-using Spring.Objects.Factory;
+using System.Collections.Generic;
+
using Spring.Objects.Factory.Config;
using Spring.Util;
@@ -56,7 +56,7 @@ namespace Spring.Objects.Factory.Support
///
/// Map from object name to object instance.
///
- private Hashtable objects = new Hashtable();
+ private Dictionary objects = new Dictionary();
///
/// Determine whether this object factory treats object names case-sensitive or not.
@@ -552,8 +552,8 @@ namespace Spring.Objects.Factory.Support
///
public string[] GetObjectDefinitionNames()
{
- ArrayList names = new ArrayList(objects.Keys);
- return (string[])names.ToArray(typeof(string));
+ List names = new List(objects.Keys);
+ return names.ToArray();
}
///
@@ -576,7 +576,7 @@ namespace Spring.Objects.Factory.Support
///
public string[] GetObjectDefinitionNames(Type type)
{
- ArrayList matches = new ArrayList();
+ List matches = new List();
foreach (string name in objects.Keys)
{
Type t = objects[name].GetType();
@@ -585,7 +585,7 @@ namespace Spring.Objects.Factory.Support
matches.Add(name);
}
}
- return (string[])matches.ToArray(typeof(string));
+ return matches.ToArray();
}
///
@@ -677,7 +677,7 @@ namespace Spring.Objects.Factory.Support
Type type, bool includePrototypes, bool includeFactoryObjects)
{
bool isFactoryType = (type != null && typeof(IFactoryObject).IsAssignableFrom(type));
- IList matches = new ArrayList();
+ List matches = new List();
foreach (string name in objects.Keys)
{
object instance = objects[name];
@@ -700,7 +700,7 @@ namespace Spring.Objects.Factory.Support
}
}
}
- return (string[])ArrayList.Adapter(matches).ToArray(typeof(string));
+ return matches.ToArray();
}
///
@@ -783,7 +783,7 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType(Type type)
+ public IDictionary GetObjectsOfType(Type type)
{
return GetObjectsOfType(type, true, true);
}
@@ -815,9 +815,9 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType()
+ public IDictionary GetObjectsOfType()
{
- return GetObjectsOfType(typeof(T));
+ return (IDictionary) GetObjectsOfType(typeof(T));
}
///
@@ -846,10 +846,10 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
bool isFactoryType = (type != null && typeof(IFactoryObject).IsAssignableFrom(type));
- IDictionary matches = new Hashtable();
+ IDictionary matches = new Dictionary();
foreach (string name in objects.Keys)
{
object instance = objects[name];
@@ -894,12 +894,12 @@ namespace Spring.Objects.Factory.Support
/// The (class or interface) to match.
///
///
- /// Whether to include prototype objects too or just singletons (also applies to
- /// s).
+ /// Whether to include prototype objects too or just singletons (also applies to
+ /// s).
///
///
- /// Whether to include s too
- /// or just normal objects.
+ /// Whether to include s too
+ /// or just normal objects.
///
///
/// A of the matching objects,
@@ -909,9 +909,9 @@ namespace Spring.Objects.Factory.Support
///
/// If the objects could not be created.
///
- public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
{
- return GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects);
+ return (IDictionary) GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects);
}
///
diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserSupport.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserSupport.cs
index 7278f2cf..86294bc3 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserSupport.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserSupport.cs
@@ -18,7 +18,7 @@
#endregion
-using System.Collections;
+using System.Collections.Generic;
using System.Xml;
using Spring.Objects.Factory.Config;
using Spring.Util;
@@ -37,7 +37,7 @@ namespace Spring.Objects.Factory.Xml
public abstract class NamespaceParserSupport : INamespaceParser
{
- private readonly IDictionary objectParsers = new Hashtable();
+ private readonly IDictionary objectParsers = new Dictionary();
#region IXmlObjectDefinitionParser Members
@@ -94,8 +94,8 @@ namespace Spring.Objects.Factory.Xml
private IObjectDefinitionParser FindParserForElement(XmlElement element, ParserContext parserContext)
{
- IObjectDefinitionParser parser = objectParsers[element.LocalName] as IObjectDefinitionParser;
- if (parser == null)
+ IObjectDefinitionParser parser;
+ if (!objectParsers.TryGetValue(element.LocalName, out parser))
{
parserContext.ReaderContext.ReportException(element, "unknown object name", "Cannot locate IObjectDefinitionParser for element ["
+ element.LocalName + "]");
diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs
index 20b68990..b8fb31bc 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs
@@ -19,12 +19,12 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
-using System.Reflection;
using System.Xml;
+
using Common.Logging;
-using Spring.Collections;
+
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Util;
@@ -55,7 +55,7 @@ namespace Spring.Objects.Factory.Xml
private readonly ObjectsNamespaceParser objectsNamespaceParser;
- private readonly ISet usedNames = new HashedSet();
+ private readonly HashSet usedNames = new HashSet();
#endregion
@@ -258,7 +258,7 @@ namespace Spring.Objects.Factory.Xml
{
string id = GetAttributeValue(element, ObjectDefinitionConstants.IdAttribute);
string nameAttr = GetAttributeValue(element, ObjectDefinitionConstants.NameAttribute);
- ArrayList aliases = new ArrayList();
+ List aliases = new List();
if (StringUtils.HasText(nameAttr))
{
aliases.AddRange(GetObjectNames(nameAttr));
@@ -274,7 +274,7 @@ namespace Spring.Objects.Factory.Xml
aliases.RemoveAt(0);
if (log.IsDebugEnabled)
{
- log.Debug(string.Format("No XML 'id' specified using '{0}' as object name and '{1}' as aliases", objectName, string.Join(",", (string[]) aliases.ToArray(typeof(string)))));
+ log.Debug(string.Format("No XML 'id' specified using '{0}' as object name and '{1}' as aliases", objectName, string.Join(",", aliases.ToArray())));
}
}
}
@@ -322,7 +322,7 @@ namespace Spring.Objects.Factory.Xml
#endregion
}
- string[] aliasesArray = (string[])aliases.ToArray(typeof(string));
+ string[] aliasesArray = aliases.ToArray();
return CreateObjectDefinitionHolder(element, definition, objectName, aliasesArray);
}
return null;
@@ -351,7 +351,7 @@ namespace Spring.Objects.Factory.Xml
/// the currently processed element.
/// the containing object definition, may be null
/// the new object name to be used.
- protected virtual string PostProcessObjectNameAndAliases(string objectName, ArrayList aliases, XmlElement element, IObjectDefinition containingDefinition)
+ protected virtual string PostProcessObjectNameAndAliases(string objectName, List aliases, XmlElement element, IObjectDefinition containingDefinition)
{
if (!StringUtils.HasText(objectName) && aliases.Count == 0)
{
@@ -367,7 +367,7 @@ namespace Spring.Objects.Factory.Xml
///
/// Validate that the specified object name and aliases have not been used already.
///
- protected virtual void CheckNameUniqueness(string objectName, ArrayList aliases, XmlElement element)
+ protected virtual void CheckNameUniqueness(string objectName, List aliases, XmlElement element)
{
string foundName = null;
@@ -385,7 +385,10 @@ namespace Spring.Objects.Factory.Xml
}
this.usedNames.Add(objectName);
- this.usedNames.AddAll(aliases);
+ foreach (string alias in aliases)
+ {
+ this.usedNames.Add(alias);
+ }
}
///
diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs
index 49380724..f4644ebd 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
@@ -407,7 +408,7 @@ namespace Spring.Objects.Factory.Xml
/// A calculated object definition id.
///
[Obsolete("This method will be dropped, override ObjectDefinitionParserHelper.PostProcessObjectNameAndAliases instead", false)]
- protected internal virtual string CalculateId(XmlElement element, ArrayList aliases)
+ protected internal virtual string CalculateId(XmlElement element, List aliases)
{
return null;
}
diff --git a/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs b/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs
index 5f7b989b..e8833b7d 100644
--- a/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs
+++ b/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Spring.Util;
@@ -53,7 +54,7 @@ namespace Spring.Objects
///
/// The list of objects.
///
- private IList propertyValuesList = new ArrayList();
+ private List propertyValuesList = new List();
#endregion
@@ -121,7 +122,7 @@ namespace Spring.Objects
///
public PropertyValue[] PropertyValues
{
- get { return (PropertyValue[]) ArrayList.Adapter (propertyValuesList).ToArray (typeof (PropertyValue)); }
+ get { return propertyValuesList.ToArray(); }
}
#endregion
diff --git a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs
index 56a5ce3b..21548822 100644
--- a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs
+++ b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Text;
@@ -331,7 +332,7 @@ namespace Spring.Objects
///
public virtual void SetPropertyValues(IPropertyValues propertyValues, bool ignoreUnknown)
{
- ArrayList propertyAccessExceptions = new ArrayList();
+ List propertyAccessExceptions = new List();
foreach (PropertyValue pv in propertyValues)
{
try
@@ -374,8 +375,7 @@ namespace Spring.Objects
// if we encountered individual exceptions, throw the composite exception...
if (propertyAccessExceptions.Count > 0)
{
- throw new PropertyAccessExceptionsException(this,
- (PropertyAccessException[]) propertyAccessExceptions.ToArray(typeof(PropertyAccessException)));
+ throw new PropertyAccessExceptionsException(this, propertyAccessExceptions.ToArray());
}
}
diff --git a/src/Spring/Spring.Core/Objects/Support/MethodInvoker.cs b/src/Spring/Spring.Core/Objects/Support/MethodInvoker.cs
index b257cd45..3d935005 100644
--- a/src/Spring/Spring.Core/Objects/Support/MethodInvoker.cs
+++ b/src/Spring/Spring.Core/Objects/Support/MethodInvoker.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
@@ -330,7 +331,7 @@ namespace Spring.Objects.Support
// lets slot in all of the named arguments first...
ParameterInfo[] parameters = _methodObject.GetParameters();
// lets figure out the index og each of the method parameters...
- IDictionary argumentNamesToIndexes = new Hashtable();
+ IDictionary argumentNamesToIndexes = new Dictionary();
for (int i = 0; i < parameters.Length; ++i)
{
ParameterInfo parameter = parameters[i];
@@ -341,7 +342,7 @@ namespace Spring.Objects.Support
{
string argumentName = ((string) namedArgument.Key).ToLower(CultureInfo.InvariantCulture);
object argumentValue = namedArgument.Value;
- if (!argumentNamesToIndexes.Contains(argumentName))
+ if (!argumentNamesToIndexes.ContainsKey(argumentName))
{
// whoa (Nelly); the named argument does not exist on the method...
throw new ArgumentException(string.Format(
@@ -358,7 +359,7 @@ namespace Spring.Objects.Support
}
// and then fill in any remaining blanks with the plain vanilla arguments...
int plainVanillaIndex = 0;
- int[] sortedIndexes = (int[]) new ArrayList(argumentNamesToIndexes.Values).ToArray(typeof (int));
+ int[] sortedIndexes = new List(argumentNamesToIndexes.Values).ToArray();
Array.Sort(sortedIndexes);
foreach (int argumentIndex in sortedIndexes)
{
@@ -431,8 +432,7 @@ namespace Spring.Objects.Support
new MemberFilter(new CriteriaMemberFilter().FilterMemberByCriteria),
searchCriteria);
- if (matchingMethods == null
- || matchingMethods.Length == 0)
+ if (matchingMethods.Length == 0)
{
throw new MissingMethodException(targetType.Name, TargetMethod);
}
diff --git a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
index 3fac325c..93f8b50d 100644
--- a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
+++ b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.Serialization;
@@ -348,8 +349,7 @@ namespace Spring.Proxy
{
ArrayList attributes = new ArrayList();
- if (this.ProxyTargetAttributes &&
- !type.Equals(typeof(object)))
+ if (this.ProxyTargetAttributes && !type.Equals(typeof(object)))
{
// add attributes that apply to the target type
attributes.AddRange(ReflectionUtils.GetCustomAttributes(type));
@@ -470,8 +470,7 @@ namespace Spring.Proxy
object[] attrs = paramInfo.GetCustomAttributes(false);
try
{
- System.Collections.Generic.IList attrsData =
- CustomAttributeData.GetCustomAttributes(paramInfo);
+ IList attrsData = CustomAttributeData.GetCustomAttributes(paramInfo);
if (attrs.Length != attrsData.Count)
{
@@ -643,7 +642,7 @@ namespace Spring.Proxy
IProxyMethodBuilder proxyMethodBuilder, Type intf,
Type targetType, bool proxyVirtualMethods)
{
- IDictionary methodMap = new Hashtable();
+ Dictionary methodMap = new Dictionary();
InterfaceMapping mapping = GetInterfaceMapping(targetType, intf);
@@ -773,8 +772,7 @@ namespace Spring.Proxy
protected virtual void InheritType(TypeBuilder typeBuilder,
IProxyMethodBuilder proxyMethodBuilder, Type type, bool declaredMembersOnly)
{
- IDictionary methodMap = new Hashtable();
- IList finalMethods = new ArrayList();
+ IDictionary methodMap = new Dictionary();
BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
if (declaredMembersOnly)
@@ -816,10 +814,12 @@ namespace Spring.Proxy
/// The property to proxy.
/// The implemented methods map.
protected virtual void ImplementProperty(
- TypeBuilder typeBuilder, Type type, PropertyInfo property, IDictionary methodMap)
+ TypeBuilder typeBuilder, Type type, PropertyInfo property, IDictionary methodMap)
{
- MethodBuilder getMethod = methodMap["get_" + property.Name] as MethodBuilder;
- MethodBuilder setMethod = methodMap["set_" + property.Name] as MethodBuilder;
+ MethodBuilder getMethod;
+ methodMap.TryGetValue("get_" + property.Name, out getMethod);
+ MethodBuilder setMethod;
+ methodMap.TryGetValue("set_" + property.Name, out setMethod);
if (getMethod != null || setMethod != null)
{
@@ -842,18 +842,19 @@ namespace Spring.Proxy
}
}
- ///
- /// Implements the specified event.
- ///
- /// The type builder to use.
- /// The type the event is defined on.
- /// The event to proxy.
- /// The implemented methods map.
- protected virtual void ImplementEvent(
- TypeBuilder typeBuilder, Type type, EventInfo evt, IDictionary methodMap)
+ ///
+ /// Implements the specified event.
+ ///
+ /// The type builder to use.
+ /// The type the event is defined on.
+ /// The event to proxy.
+ /// The implemented methods map.
+ protected virtual void ImplementEvent(TypeBuilder typeBuilder, Type type, EventInfo evt, IDictionary methodMap)
{
- MethodBuilder addOnMethod = methodMap["add_" + evt.Name] as MethodBuilder;
- MethodBuilder removeOnMethod = methodMap["remove_" + evt.Name] as MethodBuilder;
+ MethodBuilder addOnMethod;
+ methodMap.TryGetValue("add_" + evt.Name, out addOnMethod);
+ MethodBuilder removeOnMethod;
+ methodMap.TryGetValue("remove_" + evt.Name, out removeOnMethod);
if (addOnMethod != null && removeOnMethod != null)
{
@@ -889,7 +890,7 @@ namespace Spring.Proxy
///
protected virtual Type[] GetProxiableInterfaces(Type[] interfaces)
{
- ArrayList proxiableInterfaces = new ArrayList();
+ List proxiableInterfaces = new List();
foreach(Type intf in interfaces)
{
@@ -913,7 +914,7 @@ namespace Spring.Proxy
}
}
- return (Type[]) proxiableInterfaces.ToArray(typeof(Type));
+ return proxiableInterfaces.ToArray();
}
///
diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicConstructor.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicConstructor.cs
index 14bf3ab9..53f2702c 100644
--- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicConstructor.cs
+++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicConstructor.cs
@@ -20,7 +20,7 @@
#region Imports
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Spring.Util;
@@ -65,15 +65,15 @@ namespace Spring.Reflection.Dynamic
#region Generated Function Cache
- private static readonly IDictionary constructorCache = new Hashtable();
+ private static readonly IDictionary constructorCache = new Dictionary();
///
/// Obtains cached constructor info or creates a new entry, if none is found.
///
private static ConstructorDelegate GetOrCreateDynamicConstructor(ConstructorInfo constructorInfo)
{
- ConstructorDelegate method = (ConstructorDelegate)constructorCache[constructorInfo];
- if (method == null)
+ ConstructorDelegate method;
+ if (!constructorCache.TryGetValue(constructorInfo, out method))
{
method = DynamicReflectionManager.CreateConstructor(constructorInfo);
lock (constructorCache)
diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicField.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicField.cs
index 2ad5de97..c362d373 100644
--- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicField.cs
+++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicField.cs
@@ -20,7 +20,7 @@
#region Imports
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Spring.Util;
@@ -76,7 +76,7 @@ namespace Spring.Reflection.Dynamic
#region Cache
- private static readonly IDictionary fieldCache = new Hashtable();
+ private static readonly IDictionary fieldCache = new Dictionary();
///
/// Holds cached Getter/Setter delegates for a Field
@@ -98,8 +98,8 @@ namespace Spring.Reflection.Dynamic
///
private static DynamicFieldCacheEntry GetOrCreateDynamicField(FieldInfo field)
{
- DynamicFieldCacheEntry fieldInfo = (DynamicFieldCacheEntry)fieldCache[field];
- if (fieldInfo == null)
+ DynamicFieldCacheEntry fieldInfo;
+ if (!fieldCache.TryGetValue(field, out fieldInfo))
{
fieldInfo = new DynamicFieldCacheEntry(DynamicReflectionManager.CreateFieldGetter(field), DynamicReflectionManager.CreateFieldSetter(field));
lock (fieldCache)
diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs
index 563f686f..d4198631 100644
--- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs
+++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicProperty.cs
@@ -20,9 +20,11 @@
#region Imports
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
+
using Common.Logging;
+
using Spring.Util;
#endregion
@@ -103,7 +105,7 @@ namespace Spring.Reflection.Dynamic
#region Cache
- private static readonly IDictionary propertyCache = new Hashtable();
+ private static readonly IDictionary propertyCache = new Dictionary();
///
/// Holds cached Getter/Setter delegates for a Property
@@ -125,8 +127,8 @@ namespace Spring.Reflection.Dynamic
///
private static DynamicPropertyCacheEntry GetOrCreateDynamicProperty(PropertyInfo property)
{
- DynamicPropertyCacheEntry propertyInfo = (DynamicPropertyCacheEntry)propertyCache[property];
- if (propertyInfo == null)
+ DynamicPropertyCacheEntry propertyInfo;
+ if (!propertyCache.TryGetValue(property, out propertyInfo))
{
propertyInfo = new DynamicPropertyCacheEntry(DynamicReflectionManager.CreatePropertyGetter(property), DynamicReflectionManager.CreatePropertySetter(property));
lock (propertyCache)
diff --git a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicReflectionManager.cs b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicReflectionManager.cs
index 19300dce..5a8fc56a 100644
--- a/src/Spring/Spring.Core/Reflection/Dynamic/DynamicReflectionManager.cs
+++ b/src/Spring/Spring.Core/Reflection/Dynamic/DynamicReflectionManager.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
@@ -126,27 +127,32 @@ namespace Spring.Reflection.Dynamic
///
/// Cache for dynamic property types.
///
- private readonly static IDictionary propertyCache = new Hashtable();
+ private readonly static IDictionary propertyCache = new Dictionary();
+ private readonly static object propertyCacheLock = new object();
///
/// Cache for dynamic field types.
///
- private readonly static IDictionary fieldCache = new Hashtable();
+ private readonly static IDictionary fieldCache = new Dictionary();
+ private readonly static object fieldCacheLock = new object();
///
/// Cache for dynamic indexer types.
///
- private readonly static IDictionary indexerCache = new Hashtable();
+ private readonly static IDictionary indexerCache = new Dictionary();
+ private readonly static object indexerCacheLock = new object();
///
/// Cache for dynamic method types.
///
- private readonly static IDictionary methodCache = new Hashtable();
+ private readonly static IDictionary methodCache = new Dictionary();
+ private readonly static object methodCacheLock = new object();
///
/// Cache for dynamic constructor types.
///
- private readonly static IDictionary constructorCache = new Hashtable();
+ private readonly static IDictionary constructorCache = new Dictionary();
+ private readonly static object constructorCacheLock = new object();
#endregion
@@ -175,10 +181,10 @@ namespace Spring.Reflection.Dynamic
/// An for the given property info.
internal static IDynamicProperty GetDynamicProperty(PropertyInfo property, CreatePropertyCallback createCallback)
{
- lock (propertyCache.SyncRoot)
+ lock (propertyCacheLock)
{
- IDynamicProperty dynamicProperty = (IDynamicProperty)propertyCache[property];
- if (dynamicProperty == null)
+ IDynamicProperty dynamicProperty;
+ if (!propertyCache.TryGetValue(property, out dynamicProperty))
{
dynamicProperty = createCallback(property);
propertyCache[property] = dynamicProperty;
@@ -195,10 +201,10 @@ namespace Spring.Reflection.Dynamic
/// An for the given field info.
internal static IDynamicField GetDynamicField(FieldInfo field, CreateFieldCallback createCallback)
{
- lock (fieldCache.SyncRoot)
+ lock (fieldCacheLock)
{
- IDynamicField dynamicField = (IDynamicField)fieldCache[field];
- if (dynamicField == null)
+ IDynamicField dynamicField;
+ if (!fieldCache.TryGetValue(field, out dynamicField))
{
dynamicField = createCallback(field);
fieldCache[field] = dynamicField;
@@ -215,10 +221,10 @@ namespace Spring.Reflection.Dynamic
/// An for the given indexer.
internal static IDynamicIndexer GetDynamicIndexer(PropertyInfo indexer, CreateIndexerCallback createCallback)
{
- lock (indexerCache.SyncRoot)
+ lock (indexerCacheLock)
{
- IDynamicIndexer dynamicIndexer = (IDynamicIndexer)indexerCache[indexer];
- if (dynamicIndexer == null)
+ IDynamicIndexer dynamicIndexer;
+ if (!indexerCache.TryGetValue(indexer, out dynamicIndexer))
{
dynamicIndexer = createCallback(indexer);
indexerCache[indexer] = dynamicIndexer;
@@ -235,10 +241,10 @@ namespace Spring.Reflection.Dynamic
/// An for the given method.
internal static IDynamicMethod GetDynamicMethod(MethodInfo method, CreateMethodCallback createCallback)
{
- lock (methodCache.SyncRoot)
+ lock (methodCacheLock)
{
- IDynamicMethod dynamicMethod = (IDynamicMethod)methodCache[method];
- if (dynamicMethod == null)
+ IDynamicMethod dynamicMethod;
+ if (!methodCache.TryGetValue(method, out dynamicMethod))
{
dynamicMethod = createCallback(method);
methodCache[method] = dynamicMethod;
@@ -255,10 +261,10 @@ namespace Spring.Reflection.Dynamic
/// An for the given constructor.
internal static IDynamicConstructor GetDynamicConstructor(ConstructorInfo constructor, CreateConstructorCallback createCallback)
{
- lock (constructorCache.SyncRoot)
+ lock (constructorCacheLock)
{
- IDynamicConstructor dynamicConstructor = (IDynamicConstructor)constructorCache[constructor];
- if (dynamicConstructor == null)
+ IDynamicConstructor dynamicConstructor;
+ if (!constructorCache.TryGetValue(constructor, out dynamicConstructor))
{
dynamicConstructor = createCallback(constructor);
constructorCache[constructor] = dynamicConstructor;
diff --git a/src/Spring/Spring.Core/Util/EventUtils.cs b/src/Spring/Spring.Core/Util/EventUtils.cs
index 5b2e822e..a3a71d6c 100644
--- a/src/Spring/Spring.Core/Util/EventUtils.cs
+++ b/src/Spring/Spring.Core/Util/EventUtils.cs
@@ -19,9 +19,10 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
+
using Common.Logging;
namespace Spring.Util
@@ -34,11 +35,11 @@ namespace Spring.Util
{
protected class EventExceptionsCollector : IEventExceptionsCollector
{
- private readonly Hashtable _eventExceptions;
+ private readonly Dictionary _eventExceptions;
public EventExceptionsCollector()
{
- _eventExceptions = new Hashtable();
+ _eventExceptions = new Dictionary();
}
public bool HasExceptions
@@ -48,17 +49,22 @@ namespace Spring.Util
public Delegate[] Sources
{
- get { return (Delegate[]) CollectionUtils.ToArray(_eventExceptions.Keys, typeof(Delegate)); }
+ get { return new List(_eventExceptions.Keys).ToArray(); }
}
public Exception[] Exceptions
{
- get { return (Exception[]) CollectionUtils.ToArray(_eventExceptions.Values, typeof (Exception)); }
+ get { return new List(_eventExceptions.Values).ToArray(); }
}
public Exception this[Delegate source]
{
- get { return (Exception) _eventExceptions[source]; }
+ get
+ {
+ Exception exception;
+ _eventExceptions.TryGetValue(source, out exception);
+ return exception;
+ }
}
public void Add(Delegate source, Exception exception)
diff --git a/src/Spring/Spring.Core/Util/ReflectionUtils.cs b/src/Spring/Spring.Core/Util/ReflectionUtils.cs
index 604dc8f1..625b59a3 100644
--- a/src/Spring/Spring.Core/Util/ReflectionUtils.cs
+++ b/src/Spring/Spring.Core/Util/ReflectionUtils.cs
@@ -552,10 +552,10 @@ namespace Spring.Util
intf.FullName));
}
- ArrayList interfaces = new ArrayList(intf.GetInterfaces());
+ List interfaces = new List(intf.GetInterfaces());
interfaces.Add(intf);
- return (Type[])interfaces.ToArray(typeof(Type));
+ return interfaces.ToArray();
}
///
@@ -942,9 +942,9 @@ namespace Spring.Util
{
}
- IList getSetProps = new ArrayList();
+ IList getSetProps = new List();
IList getSetValues = new ArrayList();
- IList readOnlyProps = new ArrayList();
+ IList readOnlyProps = new List();
IList readOnlyValues = new ArrayList();
foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
@@ -976,7 +976,7 @@ namespace Spring.Util
if (readOnlyProps.Count == 1)
{
- PropertyInfo pi = readOnlyProps[0] as PropertyInfo;
+ PropertyInfo pi = readOnlyProps[0];
ConstructorInfo ciTemp = type.GetConstructor(new Type[1] { pi.PropertyType });
if (ciTemp != null)
{
@@ -1234,8 +1234,7 @@ namespace Spring.Util
object[] attrs = member.GetCustomAttributes(false);
try
{
- System.Collections.Generic.IList attrsData =
- CustomAttributeData.GetCustomAttributes(member);
+ IList attrsData = CustomAttributeData.GetCustomAttributes(member);
if (attrs.Length != attrsData.Count)
{
@@ -1461,10 +1460,10 @@ namespace Spring.Util
if (type.IsInterface)
{
- ArrayList interfaces = new ArrayList();
+ List interfaces = new List();
interfaces.Add(type);
interfaces.AddRange(type.GetInterfaces());
- return (Type[])interfaces.ToArray(typeof(Type));
+ return interfaces.ToArray();
}
else
{
@@ -1596,19 +1595,22 @@ namespace Spring.Util
private delegate void MemberwiseCopyHandler(object a, object b);
- private static readonly Hashtable s_handlerCache = new Hashtable();
+ private static readonly Dictionary s_handlerCache = new Dictionary();
private static MemberwiseCopyHandler GetImpl(Type type)
{
- MemberwiseCopyHandler handler = s_handlerCache[type] as MemberwiseCopyHandler;
- if (handler != null)
+ MemberwiseCopyHandler handler;
+ if (s_handlerCache.TryGetValue(type, out handler))
+ {
return handler;
+ }
lock (s_handlerCache)
{
- handler = s_handlerCache[type] as MemberwiseCopyHandler;
- if (handler != null)
+ if (s_handlerCache.TryGetValue(type, out handler))
+ {
return handler;
+ }
FieldInfo[] fields = GetFields(type);
SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate
@@ -1646,25 +1648,25 @@ namespace Spring.Util
private const BindingFlags FIELDBINDINGS =
BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic;
- private static readonly Hashtable s_fieldCache = new Hashtable();
+ private static readonly Dictionary s_fieldCache = new Dictionary();
private static FieldInfo[] GetFields(Type type)
{
lock (s_fieldCache)
{
- FieldInfo[] fields = (FieldInfo[])s_fieldCache[type];
- if (fields == null)
+ FieldInfo[] fields;
+ if (!s_fieldCache.TryGetValue(type, out fields))
{
- ArrayList fieldList = new ArrayList();
+ List fieldList = new List();
CollectFieldsRecursive(type, fieldList);
- fields = (FieldInfo[])fieldList.ToArray(typeof(FieldInfo));
+ fields = fieldList.ToArray();
s_fieldCache[type] = fields;
}
return fields;
}
}
- private static void CollectFieldsRecursive(Type type, ArrayList fieldList)
+ private static void CollectFieldsRecursive(Type type, List fieldList)
{
if (type == typeof(object))
return;
@@ -1689,8 +1691,8 @@ namespace Spring.Util
private Type type;
private ArrayList constructorArgs;
- private ArrayList namedProperties;
- private ArrayList propertyValues;
+ private List namedProperties;
+ private List propertyValues;
#endregion
@@ -1724,8 +1726,8 @@ namespace Spring.Util
}
this.type = attributeType;
this.constructorArgs = new ArrayList(constructorArgs);
- this.namedProperties = new ArrayList();
- this.propertyValues = new ArrayList();
+ this.namedProperties = new List();
+ this.propertyValues = new List();
}
#endregion
@@ -1776,8 +1778,8 @@ namespace Spring.Util
if (namedProperties.Count > 0)
{
- PropertyInfo[] npArray = (PropertyInfo[])this.namedProperties.ToArray(typeof(PropertyInfo));
- object[] pvArray = (object[])this.propertyValues.ToArray(typeof(object));
+ PropertyInfo[] npArray = this.namedProperties.ToArray();
+ object[] pvArray = this.propertyValues.ToArray();
return new CustomAttributeBuilder(ci, caArray, npArray, pvArray);
}
else
diff --git a/src/Spring/Spring.Core/Util/StringUtils.cs b/src/Spring/Spring.Core/Util/StringUtils.cs
index bc0a85e7..a0791ec4 100644
--- a/src/Spring/Spring.Core/Util/StringUtils.cs
+++ b/src/Spring/Spring.Core/Util/StringUtils.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Text;
@@ -148,7 +149,7 @@ namespace Spring.Util
{
return new string[0];
}
- if (delimiters==null || delimiters.Length==0)
+ if (string.IsNullOrEmpty(delimiters))
{
return new string[] { s };
}
@@ -164,7 +165,7 @@ namespace Spring.Util
int[] delimiterPositions = new int[s.Length];
int count = MakeDelimiterPositionList(s, delimiterChars, quoteChars, delimiterPositions);
- ArrayList tokens = new ArrayList(count+1);
+ List tokens = new List(count+1);
int startIndex = 0;
for (int ixSep = 0; ixSep < count; ixSep++)
{
@@ -200,7 +201,7 @@ namespace Spring.Util
}
}
- return (string[])tokens.ToArray(typeof(string));
+ return tokens.ToArray();
}
private static int MakeDelimiterPositionList(string s, char[] delimiters, string quoteChars, int[] delimiterPositions)
@@ -534,9 +535,9 @@ namespace Spring.Util
/// If any of the expressions in the supplied
/// is empty (${}).
///
- public static IList GetAntExpressions(string text)
+ public static IList GetAntExpressions(string text)
{
- IList expressions = new ArrayList();
+ List expressions = new List();
if (StringUtils.HasText(text))
{
int start = text.IndexOf(AntExpressionPrefix);
diff --git a/src/Spring/Spring.Core/Validation/Actions/ErrorMessageAction.cs b/src/Spring/Spring.Core/Validation/Actions/ErrorMessageAction.cs
index 9a282b48..d32560a5 100644
--- a/src/Spring/Spring.Core/Validation/Actions/ErrorMessageAction.cs
+++ b/src/Spring/Spring.Core/Validation/Actions/ErrorMessageAction.cs
@@ -20,7 +20,7 @@
using System;
using System.Collections;
-
+using System.Collections.Generic;
using Spring.Expressions;
using Spring.Util;
@@ -69,7 +69,7 @@ namespace Spring.Validation.Actions
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
ErrorMessage error = CreateErrorMessage(validationContext, contextParams);
foreach (string provider in this.providers)
@@ -84,7 +84,7 @@ namespace Spring.Validation.Actions
/// Validation context to resolve message parameters against.
/// Additional context parameters.
/// Resolved error message
- private ErrorMessage CreateErrorMessage(object validationContext, IDictionary contextParams)
+ private ErrorMessage CreateErrorMessage(object validationContext, IDictionary contextParams)
{
if (messageParams != null && messageParams.Length > 0)
{
@@ -104,7 +104,7 @@ namespace Spring.Validation.Actions
/// Validation context to resolve parameters against.
/// Additional context parameters.
/// Resolved message parameters.
- private object[] ResolveMessageParameters(IList messageParams, object validationContext, IDictionary contextParams)
+ private object[] ResolveMessageParameters(IList messageParams, object validationContext, IDictionary contextParams)
{
object[] parameters = new object[messageParams.Count];
for (int i = 0; i < messageParams.Count; i++)
diff --git a/src/Spring/Spring.Core/Validation/Actions/ExceptionAction.cs b/src/Spring/Spring.Core/Validation/Actions/ExceptionAction.cs
index 26c43c87..25597675 100644
--- a/src/Spring/Spring.Core/Validation/Actions/ExceptionAction.cs
+++ b/src/Spring/Spring.Core/Validation/Actions/ExceptionAction.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Common.Logging;
using Spring.Expressions;
using Spring.Util;
@@ -71,7 +72,7 @@ namespace Spring.Validation.Actions
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (throwsExpression != null)
{
diff --git a/src/Spring/Spring.Core/Validation/Actions/ExpressionAction.cs b/src/Spring/Spring.Core/Validation/Actions/ExpressionAction.cs
index 36a23f43..9b2eb392 100644
--- a/src/Spring/Spring.Core/Validation/Actions/ExpressionAction.cs
+++ b/src/Spring/Spring.Core/Validation/Actions/ExpressionAction.cs
@@ -19,7 +19,7 @@
#endregion
using System.Collections;
-
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation.Actions
@@ -87,7 +87,7 @@ namespace Spring.Validation.Actions
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected override void OnValid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected override void OnValid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (Valid != null)
{
@@ -101,7 +101,7 @@ namespace Spring.Validation.Actions
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected override void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (Invalid != null)
{
diff --git a/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs b/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
index c2c18442..ce8f8c87 100644
--- a/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -77,11 +78,11 @@ namespace Spring.Validation
///
/// Validates the specified object.
///
- /// The object to validate.
/// Additional context parameters.
/// instance to add error messages to.
+ /// The object to validate.
/// True if validation was successful, False otherwise.
- protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
+ protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
// capture errors in separate collection to only add them to the error collector in case of errors
ValidationErrors tmpErrors = new ValidationErrors();
diff --git a/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs b/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
index 2be336ab..719f5e01 100644
--- a/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
+++ b/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -85,7 +86,7 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
bool valid = true;
@@ -111,7 +112,7 @@ namespace Spring.Validation
/// Root context to use for expression evaluation.
/// Additional context parameters.
/// Result of the test expression evaluation, or validation context if test is null.
- protected object EvaluateTest(object rootContext, IDictionary contextParams)
+ protected object EvaluateTest(object rootContext, IDictionary contextParams)
{
if (Test == null)
{
diff --git a/src/Spring/Spring.Core/Validation/BaseValidationAction.cs b/src/Spring/Spring.Core/Validation/BaseValidationAction.cs
index 991fd189..1dca2164 100644
--- a/src/Spring/Spring.Core/Validation/BaseValidationAction.cs
+++ b/src/Spring/Spring.Core/Validation/BaseValidationAction.cs
@@ -20,7 +20,7 @@
using System;
using System.Collections;
-
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -77,7 +77,7 @@ namespace Spring.Validation
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- public virtual void Execute(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
+ public virtual void Execute(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (EvaluateWhen(validationContext, contextParams))
{
@@ -102,7 +102,7 @@ namespace Spring.Validation
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected virtual void OnValid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected virtual void OnValid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{}
///
@@ -111,7 +111,7 @@ namespace Spring.Validation
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected virtual void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected virtual void OnInvalid(object validationContext, IDictionary contextParams, IValidationErrors errors)
{}
// CLOVER:ON
@@ -126,7 +126,7 @@ namespace Spring.Validation
/// Root context to use for expression evaluation.
/// Additional context parameters.
/// True if the condition is true, False otherwise.
- protected bool EvaluateWhen(object rootContext, IDictionary contextParams)
+ protected bool EvaluateWhen(object rootContext, IDictionary contextParams)
{
if (When == null)
{
diff --git a/src/Spring/Spring.Core/Validation/BaseValidator.cs b/src/Spring/Spring.Core/Validation/BaseValidator.cs
index db8a4a11..b20a5ec0 100644
--- a/src/Spring/Spring.Core/Validation/BaseValidator.cs
+++ b/src/Spring/Spring.Core/Validation/BaseValidator.cs
@@ -19,7 +19,7 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -40,7 +40,7 @@ namespace Spring.Validation
{
#region Fields
- private IList actions = new ArrayList();
+ private IList actions = new List();
private IExpression when;
@@ -89,7 +89,7 @@ namespace Spring.Validation
/// Gets or sets the validation actions.
///
/// The actions that should be executed after validation.
- public IList Actions
+ public IList Actions
{
get { return actions; }
set { actions = value; }
@@ -115,7 +115,7 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public abstract bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors);
+ public abstract bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors);
#region Helper Methods
@@ -125,7 +125,7 @@ namespace Spring.Validation
/// Root context to use for expression evaluation.
/// Additional context parameters.
/// True if the condition is true, False otherwise.
- protected bool EvaluateWhen(object rootContext, IDictionary contextParams)
+ protected bool EvaluateWhen(object rootContext, IDictionary contextParams)
{
if (When == null)
{
@@ -142,7 +142,7 @@ namespace Spring.Validation
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- protected void ProcessActions(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
+ protected void ProcessActions(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (actions != null && actions.Count > 0)
{
diff --git a/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs b/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
index dc49d600..575760fa 100644
--- a/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -87,7 +88,7 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (EvaluateWhen(validationContext, contextParams))
{
@@ -102,10 +103,10 @@ namespace Spring.Validation
///
/// Actual implementation how to validate the specified object.
///
- /// The object to validate.
/// Additional context parameters.
/// instance to add error messages to.
+ /// The object to validate.
/// True if validation was successful, False otherwise.
- protected abstract bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext);
+ protected abstract bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/CollectionValidator.cs b/src/Spring/Spring.Core/Validation/CollectionValidator.cs
index 9554d65c..07e5d110 100644
--- a/src/Spring/Spring.Core/Validation/CollectionValidator.cs
+++ b/src/Spring/Spring.Core/Validation/CollectionValidator.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -159,7 +160,7 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
if (Context != null)
{
@@ -177,11 +178,11 @@ namespace Spring.Validation
///
/// Actual implementation how to validate the specified object.
///
- /// The object to validate.
/// Additional context parameters.
/// instance to add error messages to.
+ /// The object to validate.
/// True if validation was successful, False otherwise.
- protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
+ protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
bool valid = true;
IEnumerable collectionToValidate = (validationContext is IDictionary
diff --git a/src/Spring/Spring.Core/Validation/Config/ValidationNamespaceParser.cs b/src/Spring/Spring.Core/Validation/Config/ValidationNamespaceParser.cs
index 98f36076..ea017e08 100644
--- a/src/Spring/Spring.Core/Validation/Config/ValidationNamespaceParser.cs
+++ b/src/Spring/Spring.Core/Validation/Config/ValidationNamespaceParser.cs
@@ -21,18 +21,16 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Xml;
using Spring.Core.TypeResolution;
-using Spring.Context.Support;
using Spring.Expressions;
using Spring.Objects;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Objects.Factory.Xml;
-using Spring.Threading;
using Spring.Util;
#endregion
@@ -251,7 +249,7 @@ namespace Spring.Validation.Config
{
string messageId = GetAttributeValue(message, MessageConstants.IdAttribute);
string[] providers = GetAttributeValue(message, MessageConstants.ProvidersAttribute).Split(',');
- ArrayList parameters = new ArrayList();
+ List parameters = new List();
foreach (XmlElement param in message.ChildNodes)
{
@@ -272,7 +270,7 @@ namespace Spring.Validation.Config
}
if (parameters.Count > 0)
{
- properties.Add("Parameters", parameters.ToArray(typeof(IExpression)));
+ properties.Add("Parameters", parameters.ToArray());
}
IConfigurableObjectDefinition action =
diff --git a/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs b/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
index b1c10760..4b1d80c0 100644
--- a/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -78,11 +79,11 @@ namespace Spring.Validation
///
/// Actual implementation how to validate the specified object.
///
- /// The object to validate.
/// Additional context parameters.
/// instance to add error messages to.
+ /// The object to validate.
/// True if validation was successful, False otherwise.
- protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
+ protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
ValidationErrors tmpErrors = new ValidationErrors();
bool valid = false;
diff --git a/src/Spring/Spring.Core/Validation/IValidationAction.cs b/src/Spring/Spring.Core/Validation/IValidationAction.cs
index 764d7917..26895cc7 100644
--- a/src/Spring/Spring.Core/Validation/IValidationAction.cs
+++ b/src/Spring/Spring.Core/Validation/IValidationAction.cs
@@ -21,7 +21,7 @@
#region Imports
using System.Collections;
-
+using System.Collections.Generic;
using Spring.Validation.Actions;
#endregion
@@ -51,6 +51,6 @@ namespace Spring.Validation
/// Validation context.
/// Additional context parameters.
/// Validation errors container.
- void Execute(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors);
+ void Execute(bool isValid, object validationContext, IDictionary contextParams, IValidationErrors errors);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/IValidationErrors.cs b/src/Spring/Spring.Core/Validation/IValidationErrors.cs
index 9ec469ed..010b4b0a 100644
--- a/src/Spring/Spring.Core/Validation/IValidationErrors.cs
+++ b/src/Spring/Spring.Core/Validation/IValidationErrors.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Generic;
using Spring.Context;
namespace Spring.Validation
@@ -24,7 +25,7 @@ namespace Spring.Validation
///
/// Gets the list of all error providers.
///
- IList Providers { get; }
+ IList Providers { get; }
///
/// Adds the supplied to this
@@ -68,7 +69,7 @@ namespace Spring.Validation
///
/// A list of all s for the supplied lookup .
///
- IList GetErrors(string provider);
+ IList GetErrors(string provider);
///
/// Gets the list of resolved error messages for the supplied lookup .
@@ -84,6 +85,6 @@ namespace Spring.Validation
///
/// A list of resolved error messages for the supplied lookup .
///
- IList GetResolvedErrors(string provider, IMessageSource messageSource);
+ IList GetResolvedErrors(string provider, IMessageSource messageSource);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/IValidator.cs b/src/Spring/Spring.Core/Validation/IValidator.cs
index 6b7db546..538ffeba 100644
--- a/src/Spring/Spring.Core/Validation/IValidator.cs
+++ b/src/Spring/Spring.Core/Validation/IValidator.cs
@@ -21,6 +21,7 @@
#region Imports
using System.Collections;
+using System.Collections.Generic;
#endregion
@@ -69,13 +70,13 @@ namespace Spring.Validation
/// The object to validate.
/// Additional context parameters.
///
- /// The instance to add any error
- /// messages to in the case of validation failure.
+ /// The instance to add any error
+ /// messages to in the case of validation failure.
///
///
/// if validation was successful.
///
- bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors);
+ bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/ValidationErrors.cs b/src/Spring/Spring.Core/Validation/ValidationErrors.cs
index fac5089d..f7367951 100644
--- a/src/Spring/Spring.Core/Validation/ValidationErrors.cs
+++ b/src/Spring/Spring.Core/Validation/ValidationErrors.cs
@@ -21,7 +21,7 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
@@ -91,18 +91,18 @@ namespace Spring.Validation
reader.Read();
while (reader.Name == "Provider")
{
- object key = reader.GetAttribute("Id");
+ string key = reader.GetAttribute("Id");
reader.Read();
while (reader.Name == "ErrorMessage")
{
XmlSerializer xs = new XmlSerializer(typeof(ErrorMessage));
- object value = xs.Deserialize(reader);
+ ErrorMessage value = (ErrorMessage) xs.Deserialize(reader);
- IList mapValue = (IList)errorMap[key];
+ List mapValue;
- if (mapValue == null)
+ if (!errorMap.TryGetValue(key, out mapValue))
{
- mapValue = new ArrayList();
+ mapValue = new List();
errorMap[key] = mapValue;
}
@@ -122,17 +122,16 @@ namespace Spring.Validation
///
public void WriteXml(XmlWriter writer)
{
- foreach (DictionaryEntry entry in errorMap)
+ foreach (KeyValuePair> entry in errorMap)
{
writer.WriteStartElement("Provider");
- writer.WriteAttributeString("Id", entry.Key as String);
+ writer.WriteAttributeString("Id", entry.Key);
if (entry.Value != null)
{
- ArrayList errorsList = (ArrayList)entry.Value;
- foreach (object o in errorsList)
+ IList errorsList = entry.Value;
+ foreach (ErrorMessage error in errorsList)
{
- ErrorMessage error = (ErrorMessage)o;
XmlSerializer xs = new XmlSerializer(typeof(ErrorMessage));
xs.Serialize(writer, error);
}
@@ -164,9 +163,9 @@ namespace Spring.Validation
///
/// Gets the list of all providers.
///
- public IList Providers
+ public IList Providers
{
- get { return new ArrayList(this.errorMap.Keys); }
+ get { return new List(this.errorMap.Keys); }
}
///
@@ -186,10 +185,10 @@ namespace Spring.Validation
AssertUtils.ArgumentNotNull(provider, "provider");
AssertUtils.ArgumentNotNull(message, "errorMessage");
- IList errors = (IList) errorMap[provider];
- if (errors == null)
+ List errors;
+ if (!errorMap.TryGetValue(provider, out errors))
{
- errors = new ArrayList();
+ errors = new List();
errorMap[provider] = errors;
}
errors.Add(message);
@@ -214,15 +213,15 @@ namespace Spring.Validation
{
foreach(string provider in errorsToMerge.Providers)
{
- ArrayList errList = (ArrayList) this.errorMap[provider];
- IList other = errorsToMerge.GetErrors(provider);
- if (errList == null)
+ List errList;
+ List other = new List(errorsToMerge.GetErrors(provider));
+ if (!errorMap.TryGetValue(provider, out errList))
{
this.errorMap[provider] = other;
}
else
{
- errList.AddRange((IList) other);
+ errList.AddRange(other);
}
}
// foreach (DictionaryEntry errorEntry in errorsToMerge.errorMap)
@@ -253,10 +252,11 @@ namespace Spring.Validation
///
/// A list of all s for the supplied lookup .
///
- public IList GetErrors(string provider)
+ public IList GetErrors(string provider)
{
- IList errors = (IList) errorMap[provider];
- return errors == null ? ObjectUtils.EmptyObjects : errors;
+ List errors;
+ errorMap.TryGetValue(provider, out errors);
+ return errors ?? new List(0);
}
///
@@ -273,14 +273,13 @@ namespace Spring.Validation
///
/// A list of resolved error messages for the supplied lookup .
///
- public IList GetResolvedErrors(string provider, IMessageSource messageSource)
+ public IList GetResolvedErrors(string provider, IMessageSource messageSource)
{
AssertUtils.ArgumentNotNull(provider, "provider");
- IList messages = new ArrayList();
- IList errors = (IList) errorMap[provider];
-
- if (errors != null)
+ IList messages = new List();
+ List errors;
+ if (errorMap.TryGetValue(provider, out errors))
{
foreach (ErrorMessage error in errors)
{
@@ -295,7 +294,7 @@ namespace Spring.Validation
#region Data members
- private readonly IDictionary errorMap = new Hashtable();
+ private readonly IDictionary> errorMap = new Dictionary>();
#endregion
}
diff --git a/src/Spring/Spring.Core/Validation/ValidatorGroup.cs b/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
index bc12c485..d2b07660 100644
--- a/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using Spring.Expressions;
namespace Spring.Validation
@@ -70,11 +71,11 @@ namespace Spring.Validation
///
/// Actual implementation how to validate the specified object.
///
- /// The object to validate.
/// Additional context parameters.
/// instance to add error messages to.
+ /// The object to validate.
/// True if validation was successful, False otherwise.
- protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
+ protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
bool valid = true;
foreach (IValidator validator in this.Validators)
diff --git a/src/Spring/Spring.Core/Validation/ValidatorReference.cs b/src/Spring/Spring.Core/Validation/ValidatorReference.cs
index 67bac40d..41f182b1 100644
--- a/src/Spring/Spring.Core/Validation/ValidatorReference.cs
+++ b/src/Spring/Spring.Core/Validation/ValidatorReference.cs
@@ -19,7 +19,7 @@
#endregion
using System.Collections;
-
+using System.Collections.Generic;
using Spring.Expressions;
using Spring.Objects.Factory;
using System;
@@ -136,7 +136,7 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ public bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
{
bool valid = true;
diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs
index 23f41534..00db9298 100644
--- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs
+++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs
@@ -89,7 +89,7 @@ namespace Spring.Data.NHibernate
private string[] configFilenames;
- private IDictionary hibernateProperties;
+ private IDictionary hibernateProperties;
private IDbProvider dbProvider;
@@ -223,13 +223,13 @@ namespace Spring.Data.NHibernate
/// provider settings and use a Spring-set IDbProvider instead.
///
///
- public IDictionary HibernateProperties
+ public IDictionary HibernateProperties
{
get
{
if (hibernateProperties == null)
{
- hibernateProperties = new Hashtable();
+ hibernateProperties = new Dictionary();
}
return hibernateProperties;
}
@@ -506,7 +506,7 @@ namespace Spring.Data.NHibernate
{
// Register specified Hibernate type definitions.
IDictionary typedProperties = new Dictionary();
- foreach (DictionaryEntry entry in hibernateProperties)
+ foreach (KeyValuePair entry in hibernateProperties)
{
typedProperties.Add((string) entry.Key, (string) entry.Value);
}
@@ -536,7 +536,7 @@ namespace Spring.Data.NHibernate
// check whether proxy factory has been initialized
if (config.GetProperty(Environment.ProxyFactoryFactoryClass) == null
- && (hibernateProperties == null || !hibernateProperties.Contains(Environment.ProxyFactoryFactoryClass)))
+ && (hibernateProperties == null || !hibernateProperties.ContainsKey(Environment.ProxyFactoryFactoryClass)))
{
// nothing set by user, lets use Spring.NET's proxy factory factory
#region Logging
@@ -552,7 +552,7 @@ namespace Spring.Data.NHibernate
if (this.hibernateProperties != null)
{
if (config.GetProperty(Environment.ConnectionProvider) != null &&
- hibernateProperties.Contains(Environment.ConnectionProvider))
+ hibernateProperties.ContainsKey(Environment.ConnectionProvider))
{
#region Logging
if (log.IsInfoEnabled)
@@ -565,9 +565,9 @@ namespace Spring.Data.NHibernate
}
Dictionary genericHibernateProperties = new Dictionary();
- foreach (DictionaryEntry entry in hibernateProperties)
+ foreach (KeyValuePair entry in hibernateProperties)
{
- genericHibernateProperties.Add((string) entry.Key, (string) entry.Value);
+ genericHibernateProperties.Add(entry.Key, entry.Value);
}
config.AddProperties(genericHibernateProperties);
}
diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs
index d7427c7b..c85bb43a 100644
--- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs
+++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionHolder.cs
@@ -20,12 +20,12 @@
#region Imports
-using System;
using System.Collections;
+using System.Collections.Generic;
using System.Data;
using Common.Logging;
using NHibernate;
-using Spring.Collections;
+
using Spring.Transaction.Support;
using Spring.Util;
@@ -48,7 +48,8 @@ namespace Spring.Data.NHibernate
private static readonly object DEFAULT_KEY = new object();
- private readonly Hashtable sessionDictionary = new Hashtable(1);
+ private readonly object sessionDictionaryLock = new object();
+ private readonly Dictionary sessionDictionary = new Dictionary(1);
private IDbConnection connection;
@@ -118,10 +119,12 @@ namespace Spring.Data.NHibernate
{
get
{
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
EnsureInitialized();
- return sessionDictionary[DEFAULT_KEY] as ISession;
+ ISession session;
+ sessionDictionary.TryGetValue(DEFAULT_KEY, out session);
+ return session;
}
}
}
@@ -135,7 +138,7 @@ namespace Spring.Data.NHibernate
{
get
{
- lock(sessionDictionary.SyncRoot)
+ lock(sessionDictionaryLock)
{
EnsureInitialized();
if (sessionDictionary.Count > 0)
@@ -160,7 +163,7 @@ namespace Spring.Data.NHibernate
{
get
{
- lock(sessionDictionary.SyncRoot)
+ lock(sessionDictionaryLock)
{
EnsureInitialized();
return (sessionDictionary.Count > 0 ? false : true);
@@ -179,12 +182,12 @@ namespace Spring.Data.NHibernate
{
get
{
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
EnsureInitialized();
return (
sessionDictionary.Count == 0 ||
- (sessionDictionary.Count == 1 && sessionDictionary.Contains(DEFAULT_KEY))
+ (sessionDictionary.Count == 1 && sessionDictionary.ContainsKey(DEFAULT_KEY))
);
}
@@ -263,10 +266,12 @@ namespace Spring.Data.NHibernate
/// A hibernate session
public ISession GetSession(object key)
{
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
- EnsureInitialized();
- return sessionDictionary[key] as ISession;
+ EnsureInitialized();
+ ISession session;
+ sessionDictionary.TryGetValue(key, out session);
+ return session;
}
}
@@ -279,15 +284,15 @@ namespace Spring.Data.NHibernate
/// A hibernate session
public ISession GetValidatedSession(object key)
{
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
EnsureInitialized();
- ISession session = sessionDictionary[key] as ISession;
+ ISession session;
// Check for dangling Session that's around but already closed.
// Effectively an assertion: that should never happen in practice.
// We'll seamlessly remove the Session here, to not let it cause
// any side effects.
- if (session != null && !session.IsOpen)
+ if (sessionDictionary.TryGetValue(key, out session) && !session.IsOpen)
{
sessionDictionary.Remove(key);
session = null;
@@ -314,7 +319,7 @@ namespace Spring.Data.NHibernate
AssertUtils.ArgumentNotNull(key, "key", "Key must not be null");
AssertUtils.ArgumentNotNull(session, "session", "Session must not be null");
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
if (sessionDictionary.ContainsKey(key))
{
@@ -333,9 +338,10 @@ namespace Spring.Data.NHibernate
/// dictionary storage.
public ISession RemoveSession(object key)
{
- lock(sessionDictionary.SyncRoot)
+ lock(sessionDictionaryLock)
{
- ISession oldSession = sessionDictionary[key] as ISession;
+ ISession oldSession;
+ sessionDictionary.TryGetValue(key, out oldSession);
sessionDictionary.Remove(key);
return oldSession;
}
@@ -348,9 +354,9 @@ namespace Spring.Data.NHibernate
///
/// true if the holder contains the specified session; otherwise, false.
///
- public bool ContainsSession(object session)
+ public bool ContainsSession(ISession session)
{
- lock (sessionDictionary.SyncRoot)
+ lock (sessionDictionaryLock)
{
EnsureInitialized();
return sessionDictionary.ContainsValue(session);
diff --git a/src/Spring/Spring.Data/Dao/Support/PersistenceExceptionTranslationInterceptor.cs b/src/Spring/Spring.Data/Dao/Support/PersistenceExceptionTranslationInterceptor.cs
index 1773c476..1d0fe69c 100644
--- a/src/Spring/Spring.Data/Dao/Support/PersistenceExceptionTranslationInterceptor.cs
+++ b/src/Spring/Spring.Data/Dao/Support/PersistenceExceptionTranslationInterceptor.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using AopAlliance.Intercept;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
@@ -152,7 +153,7 @@ namespace Spring.Dao.Support
protected IPersistenceExceptionTranslator DetectPersistenceExceptionTranslators(IListableObjectFactory objectFactory)
{
// Find all translators, being careful not to activate FactoryObjects.
- IDictionary pets =
+ IDictionary pets =
ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(objectFactory,
typeof (IPersistenceExceptionTranslator), false,
false);
@@ -162,7 +163,7 @@ namespace Spring.Dao.Support
}
ChainedPersistenceExceptionTranslator cpet = new ChainedPersistenceExceptionTranslator();
- foreach (DictionaryEntry pet in pets)
+ foreach (KeyValuePair pet in pets)
{
cpet.AddTranslator((IPersistenceExceptionTranslator)pet.Value);
}
diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs
index 241d8c6b..38502d1b 100644
--- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs
+++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/CachedSession.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections;
+using System.Collections.Generic;
+
using Apache.NMS;
using Common.Logging;
using Spring.Collections;
@@ -200,7 +202,7 @@ namespace Spring.Messaging.Nms.Connections
}
// Physically close durable subscribers at time of Session close call.
- IList ToRemove = new ArrayList();
+ List ToRemove = new List();
foreach (DictionaryEntry dictionaryEntry in cachedConsumers)
{
ConsumerCacheKey key = (ConsumerCacheKey) dictionaryEntry.Key;
diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs
index 4ea87163..52229572 100644
--- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs
+++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs
@@ -20,7 +20,8 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Spring.Messaging.Nms.Core;
using Spring.Util;
@@ -34,7 +35,7 @@ namespace Spring.Messaging.Nms.Connections
/// Mark Pollack (.NET)
public class ChainedExceptionListener : IExceptionListener
{
- private ArrayList listeners = new ArrayList(2);
+ private List listeners = new List(2);
///
/// Adds the exception listener to the chain
@@ -64,10 +65,7 @@ namespace Spring.Messaging.Nms.Connections
/// The exception listeners.
public IExceptionListener[] Listeners
{
- get
- {
- return (IExceptionListener[]) listeners.ToArray(typeof (IExceptionListener));
- }
+ get { return listeners.ToArray(); }
}
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs
index 5aa4cb43..379c79a1 100644
--- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs
+++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs
@@ -21,6 +21,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Common.Logging;
using Spring.Expressions;
@@ -295,7 +296,7 @@ namespace Spring.Messaging.Nms.Listener.Adapter
object convertedMessage = ExtractMessage(message);
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
vars["convertedObject"] = convertedMessage;
//Need to parse each time since have overloaded methods and
diff --git a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs
index be41fda4..ed2edf31 100644
--- a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs
+++ b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Messaging;
using Common.Logging;
using Spring.Context;
@@ -66,10 +67,10 @@ namespace Spring.Messaging.Core
MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject();
mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate;
applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo);
- IDictionary caches = applicationContext.GetObjectsOfType(typeof(MessageQueueMetadataCache));
- foreach (DictionaryEntry entry in caches)
+ IDictionary caches = applicationContext.GetObjectsOfType();
+ foreach (KeyValuePair entry in caches)
{
- ((MessageQueueMetadataCache) entry.Value).Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
+ entry.Value.Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
}
}
diff --git a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs
index 7ac559f0..9b24f450 100644
--- a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs
+++ b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Common.Logging;
using Spring.Context;
using Spring.Messaging.Support;
@@ -39,12 +40,12 @@ namespace Spring.Messaging.Core
public void Initialize()
{
- IDictionary messageQueueDictionary = configurableApplicationContext.GetObjectsOfType(typeof(MessageQueueFactoryObject));
+ IDictionary messageQueueDictionary = configurableApplicationContext.GetObjectsOfType();
lock (itemStore.SyncRoot)
{
- foreach (DictionaryEntry entry in messageQueueDictionary)
+ foreach (KeyValuePair entry in messageQueueDictionary)
{
- MessageQueueFactoryObject mqfo = entry.Value as MessageQueueFactoryObject;
+ MessageQueueFactoryObject mqfo = entry.Value;
if (mqfo != null)
{
if (mqfo.Path != null)
diff --git a/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs
index b00f3c87..de391901 100644
--- a/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs
+++ b/src/Spring/Spring.Messaging/Messaging/Listener/MessageListenerAdapter.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Messaging;
using Common.Logging;
using Spring.Context;
@@ -460,7 +461,7 @@ namespace Spring.Messaging.Listener
/// The result returned from the listener method
protected virtual object InvokeListenerMethod(string methodName, object[] arguments)
{
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
vars["convertedObject"] = arguments[0];
if (methodName.CompareTo(DefaultHandlerMethod) != 0)
{
diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs
index bc11fd9c..2169cd22 100644
--- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs
+++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractDependencyInjectionSpringContextTests.cs
@@ -19,13 +19,12 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Spring.Context;
-using Spring.Context.Support;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
@@ -231,7 +230,7 @@ namespace Spring.Testing.Microsoft
///
protected virtual void InitManagedVariableNames()
{
- ArrayList managedVarNames = new ArrayList();
+ List managedVarNames = new List();
Type type = GetType();
do
@@ -273,7 +272,7 @@ namespace Spring.Testing.Microsoft
type = type.BaseType;
} while (type != typeof (AbstractDependencyInjectionSpringContextTests));
- this.managedVariableNames = (string[]) managedVarNames.ToArray(typeof (string));
+ this.managedVariableNames = managedVarNames.ToArray();
}
private static bool IsProtectedInstanceField(FieldInfo field)
diff --git a/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs b/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs
index 62b1ec14..dfebb50e 100644
--- a/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs
+++ b/src/Spring/Spring.Testing.NUnit/Testing/Ado/SimpleAdoTestUtils.cs
@@ -19,12 +19,14 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
+
using Common.Logging;
+
using Spring.Core.IO;
using Spring.Dao;
using Spring.Data;
@@ -153,7 +155,7 @@ namespace Spring.Testing.Ado
blockDelimiter = BLOCKDELIM_ALL_EXP;
}
- ArrayList statements = new ArrayList();
+ List statements = new List();
try
{
GetScriptBlocks(resource, statements, blockDelimiter);
@@ -183,7 +185,7 @@ namespace Spring.Testing.Ado
///
/// TBD
///
- public static void GetScriptBlocks(EncodedResource encodedResource, IList blockCollector, params Regex[] blockDelimiterPatterns)
+ public static void GetScriptBlocks(EncodedResource encodedResource, IList blockCollector, params Regex[] blockDelimiterPatterns)
{
AssertUtils.ArgumentNotNull(blockCollector, "blockCollector");
@@ -209,7 +211,7 @@ namespace Spring.Testing.Ado
}
}
- private static void Split(string text, Regex exp, IList blockCollector)
+ private static void Split(string text, Regex exp, IList blockCollector)
{
// string[] blocks = exp.Split(text);
// foreach(string block in blocks)
diff --git a/src/Spring/Spring.Web/Caching/AspNetCache.cs b/src/Spring/Spring.Web/Caching/AspNetCache.cs
index ccef7676..92588e12 100644
--- a/src/Spring/Spring.Web/Caching/AspNetCache.cs
+++ b/src/Spring/Spring.Web/Caching/AspNetCache.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Web;
using System.Web.Caching;
using Common.Logging;
@@ -166,7 +167,7 @@ namespace Spring.Caching
{
get
{
- ArrayList keys = new ArrayList();
+ List keys = new List();
foreach (DictionaryEntry entry in _cache)
{
diff --git a/src/Spring/Spring.Web/DataBinding/DataSourceItemFormatter.cs b/src/Spring/Spring.Web/DataBinding/DataSourceItemFormatter.cs
index b3053c44..56b6f310 100644
--- a/src/Spring/Spring.Web/DataBinding/DataSourceItemFormatter.cs
+++ b/src/Spring/Spring.Web/DataBinding/DataSourceItemFormatter.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
namespace Spring.DataBinding
@@ -45,7 +46,7 @@ namespace Spring.DataBinding
/// The target object
/// Variables to be used during binding
/// The current binding's direction
- public void SetBindingContext(object source, object target, IDictionary variables, BindingDirection direction)
+ public void SetBindingContext(object source, object target, IDictionary variables, BindingDirection direction)
{
// Extract dataSource from source object
IEnumerable dataSource = DataBinder.GetPropertyValue(source, this._dataSourceFieldName) as IEnumerable;
diff --git a/src/Spring/Spring.Web/DataBinding/HttpRequestBindingContainer.cs b/src/Spring/Spring.Web/DataBinding/HttpRequestBindingContainer.cs
index 78189c5d..b8da1e79 100644
--- a/src/Spring/Spring.Web/DataBinding/HttpRequestBindingContainer.cs
+++ b/src/Spring/Spring.Web/DataBinding/HttpRequestBindingContainer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
@@ -85,18 +86,18 @@ namespace Spring.DataBinding
/// Binds source object to target object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables)
+ public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
NameValueCollection parameters = VirtualEnvironment.RequestParams;
IList targetList = targetExpression.GetValue(target) as IList;
@@ -110,7 +111,7 @@ namespace Spring.DataBinding
int valueCount = parameters.GetValues(requestParams[0]).Length;
for (int i = 0; i < valueCount; i++)
{
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
foreach (string paramName in requestParams)
{
vars[paramName] = parameters.GetValues(paramName)[i];
@@ -146,18 +147,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
///
///
- /// The source object.
+ /// The source object.
///
///
- /// The target object.
+ /// The target object.
///
///
- /// Validation errors collection that type conversion errors should be added to.
+ /// Validation errors collection that type conversion errors should be added to.
///
///
- /// Variables that should be used during expression evaluation.
+ /// Variables that should be used during expression evaluation.
///
- public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables)
+ public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables)
{
// can't bind to a read-only Request object...
}
diff --git a/src/Spring/Spring.Web/DataBinding/IBindingAwareFormatter.cs b/src/Spring/Spring.Web/DataBinding/IBindingAwareFormatter.cs
index 2f5b4bad..50e541b0 100644
--- a/src/Spring/Spring.Web/DataBinding/IBindingAwareFormatter.cs
+++ b/src/Spring/Spring.Web/DataBinding/IBindingAwareFormatter.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Generic;
using Spring.Globalization;
namespace Spring.DataBinding
@@ -15,7 +16,7 @@ namespace Spring.DataBinding
///
///
///
- void SetBindingContext(object source, object target, IDictionary variables, BindingDirection direction);
+ void SetBindingContext(object source, object target, IDictionary variables, BindingDirection direction);
///
/// Clears the binding context of this formatter.
///
diff --git a/src/Spring/Spring.Web/DataBinding/MultipleSelectionListControlBinding.cs b/src/Spring/Spring.Web/DataBinding/MultipleSelectionListControlBinding.cs
index 916b9cec..c217787d 100644
--- a/src/Spring/Spring.Web/DataBinding/MultipleSelectionListControlBinding.cs
+++ b/src/Spring/Spring.Web/DataBinding/MultipleSelectionListControlBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI.WebControls;
using Spring.DataBinding;
using Spring.Globalization;
@@ -35,7 +36,7 @@ namespace Spring.DataBinding
///
/// Actually performs unbinding the ListControl's selected values into the target's
///
- protected override void DoBindSourceToTarget(object source, object target, IDictionary variables)
+ protected override void DoBindSourceToTarget(object source, object target, IDictionary variables)
{
// retrieve targetlist
IList targetList = this.GetTargetValue(target,variables) as IList;
@@ -89,7 +90,7 @@ namespace Spring.DataBinding
///
/// Actually performs binding the targetlist to the ListControl.
///
- protected override void DoBindTargetToSource(object source, object target, IDictionary variables)
+ protected override void DoBindTargetToSource(object source, object target, IDictionary variables)
{
// retrieve targetlist
IList targetList = this.GetTargetValue(target, variables) as IList;
@@ -147,7 +148,7 @@ namespace Spring.DataBinding
///
/// Setting source value is not allowed in this bindingType.
///
- protected override void SetSourceValue(object source, object value, IDictionary variables)
+ protected override void SetSourceValue(object source, object value, IDictionary variables)
{
throw new InvalidOperationException(string.Format("Setting source value in '{0}' is not allowed.",this.GetType().FullName));
}
@@ -155,7 +156,7 @@ namespace Spring.DataBinding
///
/// Setting target value is not allowed in this bindingType.
///
- protected override void SetTargetValue(object target, object value, IDictionary variables)
+ protected override void SetTargetValue(object target, object value, IDictionary variables)
{
throw new InvalidOperationException(string.Format("Setting target value in '{0}' is not allowed.", this.GetType().FullName));
}
diff --git a/src/Spring/Spring.Web/Globalization/AspNetResourceCache.cs b/src/Spring/Spring.Web/Globalization/AspNetResourceCache.cs
index 01b2c260..d3f36f6d 100644
--- a/src/Spring/Spring.Web/Globalization/AspNetResourceCache.cs
+++ b/src/Spring/Spring.Web/Globalization/AspNetResourceCache.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Web;
using System.Web.Caching;
@@ -35,9 +36,9 @@ namespace Spring.Globalization
///
/// Cache key to use for lookup.
/// A list of cached resources for the specified target object and culture.
- protected override IList GetResources(string cacheKey)
+ protected override IList GetResources(string cacheKey)
{
- return (IList)HttpRuntime.Cache[cacheKey];
+ return (IList)HttpRuntime.Cache[cacheKey];
}
///
@@ -45,7 +46,7 @@ namespace Spring.Globalization
///
/// Cache key to use for the specified resources.
/// A list of resources to cache.
- protected override void PutResources(string cacheKey, IList resources)
+ protected override void PutResources(string cacheKey, IList resources)
{
HttpRuntime.Cache[cacheKey] = resources;
}
diff --git a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs
index bd3183fc..1ad9317a 100644
--- a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs
+++ b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs
@@ -19,6 +19,7 @@
#endregion
using System;
+using System.Collections.Generic;
using System.Xml;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
@@ -47,7 +48,7 @@ namespace Spring.Objects.Factory.Xml
this.webObjectNameGenerator = webObjectNameGenerator;
}
- protected override string PostProcessObjectNameAndAliases(string objectName, System.Collections.ArrayList aliases, XmlElement element, IObjectDefinition containingDefinition)
+ protected override string PostProcessObjectNameAndAliases(string objectName, List aliases, XmlElement element, IObjectDefinition containingDefinition)
{
string url = element.GetAttribute(ObjectDefinitionConstants.TypeAttribute);
string strTypeName = url.ToLower();
diff --git a/src/Spring/Spring.Web/Web/Support/MimeMediaType.cs b/src/Spring/Spring.Web/Web/Support/MimeMediaType.cs
index de9e09dd..6ea5cb7b 100644
--- a/src/Spring/Spring.Web/Web/Support/MimeMediaType.cs
+++ b/src/Spring/Spring.Web/Web/Support/MimeMediaType.cs
@@ -21,7 +21,8 @@
#region Imports
using System;
-using System.Collections;
+using System.Collections.Generic;
+
using Spring.Util;
#endregion
@@ -34,7 +35,7 @@ namespace Spring.Web.Support
/// Erich Eichinger
public class MimeMediaType
{
- private static readonly ArrayList ContentTypes = new ArrayList( new string[] {
+ private static readonly List ContentTypes = new List( new string[] {
"application", "audio", "example", "image", "message",
"model", "multipart", "text", "video"
});
diff --git a/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs b/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
index 23d97564..14f51274 100644
--- a/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
+++ b/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
@@ -21,6 +21,7 @@
#region Imports
using System.Collections;
+using System.Collections.Generic;
using Spring.Globalization;
using Spring.Objects;
using Spring.Util;
@@ -52,9 +53,9 @@ namespace Spring.Web.Support
///
/// Cache key to use for lookup.
/// A list of cached resources for the specified target object and culture.
- protected override IList GetResources(string cacheKey)
+ protected override IList GetResources(string cacheKey)
{
- return (IList) this.sharedStateHolder.SharedState[cacheKey];
+ return (IList)this.sharedStateHolder.SharedState[cacheKey];
}
///
@@ -62,7 +63,7 @@ namespace Spring.Web.Support
///
/// Cache key to use for the specified resources.
/// A list of resources to cache.
- protected override void PutResources(string cacheKey, IList resources)
+ protected override void PutResources(string cacheKey, IList resources)
{
this.sharedStateHolder.SharedState[cacheKey] = resources;
}
diff --git a/src/Spring/Spring.Web/Web/UI/Controls/AbstractValidationControl.cs b/src/Spring/Spring.Web/Web/UI/Controls/AbstractValidationControl.cs
index 86023de5..8d82eaf6 100644
--- a/src/Spring/Spring.Web/Web/UI/Controls/AbstractValidationControl.cs
+++ b/src/Spring/Spring.Web/Web/UI/Controls/AbstractValidationControl.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using Spring.Context;
using Spring.Util;
@@ -244,9 +245,9 @@ namespace Spring.Web.UI.Controls
///
///
/// a list containing elements. May return null
- protected virtual IList ResolveErrorMessages()
+ protected virtual IList ResolveErrorMessages()
{
- IList errorMessages;
+ IList errorMessages;
// good catch - idea & patch from Roberto Paterlini
if (DesignMode)
@@ -272,9 +273,7 @@ namespace Spring.Web.UI.Controls
///
protected override void Render(HtmlTextWriter writer)
{
- IList errorMessages;
-
- errorMessages = ResolveErrorMessages();
+ IList errorMessages = ResolveErrorMessages();
Renderer.RenderErrors(Page as Page, writer, errorMessages);
}
diff --git a/src/Spring/Spring.Web/Web/UI/Controls/CheckBoxList.cs b/src/Spring/Spring.Web/Web/UI/Controls/CheckBoxList.cs
index b0157e1b..5ddb4974 100644
--- a/src/Spring/Spring.Web/Web/UI/Controls/CheckBoxList.cs
+++ b/src/Spring/Spring.Web/Web/UI/Controls/CheckBoxList.cs
@@ -20,8 +20,7 @@
#region Imports
-using System.Collections;
-using System.Web.UI;
+using System.Collections.Generic;
using System.Web.UI.WebControls;
#endregion
@@ -44,12 +43,12 @@ namespace Spring.Web.UI.Controls
{
get
{
- ArrayList vals = new ArrayList();
+ List vals = new List();
foreach( ListItem item in this.Items )
{
if (item.Selected) vals.Add(item.Value);
}
- return (string[]) vals.ToArray(typeof (string));
+ return vals.ToArray();
}
set
{
@@ -59,8 +58,8 @@ namespace Spring.Web.UI.Controls
}
else
{
- ArrayList vals = new ArrayList(value);
- foreach(ListItem item in this.Items)
+ List vals = new List();
+ foreach (ListItem item in this.Items)
{
item.Selected = (vals.Contains(item.Value));
}
diff --git a/src/Spring/Spring.Web/Web/UI/Controls/LocalizedImage.cs b/src/Spring/Spring.Web/Web/UI/Controls/LocalizedImage.cs
index 4dfb66fa..f74c98be 100644
--- a/src/Spring/Spring.Web/Web/UI/Controls/LocalizedImage.cs
+++ b/src/Spring/Spring.Web/Web/UI/Controls/LocalizedImage.cs
@@ -19,7 +19,7 @@
#endregion
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.IO;
namespace Spring.Web.UI.Controls
@@ -64,19 +64,19 @@ namespace Spring.Web.UI.Controls
private string DetermineLocalizedUrl()
{
- ArrayList localeParts = new ArrayList(Page.UserCulture.Name.Split('-'));
+ List localeParts = new List(Page.UserCulture.Name.Split('-'));
while (localeParts.Count > 0 && !FileExists(localeParts))
{
localeParts.RemoveAt(localeParts.Count - 1);
}
- string locale = String.Join("-", (string[]) localeParts.ToArray(typeof(string)));
+ string locale = String.Join("-", localeParts.ToArray());
return Page.ImagesRoot + (locale.Length > 0 ? "/" + locale : "") + "/" + this.ImageName;
}
- private bool FileExists(ArrayList localeParts)
+ private bool FileExists(List localeParts)
{
- string locale = String.Join("-", (string[]) localeParts.ToArray(typeof(string)));
+ string locale = String.Join("-", localeParts.ToArray());
string url = Page.ImagesRoot + "/" + locale + "/" + this.ImageName;
return File.Exists(Page.Server.MapPath(url));
}
diff --git a/src/Spring/Spring.Web/Web/UI/Controls/RadioButtonGroup.cs b/src/Spring/Spring.Web/Web/UI/Controls/RadioButtonGroup.cs
index 01de4c2e..36272892 100644
--- a/src/Spring/Spring.Web/Web/UI/Controls/RadioButtonGroup.cs
+++ b/src/Spring/Spring.Web/Web/UI/Controls/RadioButtonGroup.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Web.UI;
@@ -40,7 +41,7 @@ namespace Spring.Web.UI.Controls
{
private static readonly object EventSelectionChanged = new object();
- private ArrayList options = new ArrayList();
+ private List options = new List();
///
/// Overloaded to track addition of contained controls.
diff --git a/src/Spring/Spring.Web/Web/UI/MasterPage.cs b/src/Spring/Spring.Web/Web/UI/MasterPage.cs
index bed54222..bbe409c7 100644
--- a/src/Spring/Spring.Web/Web/UI/MasterPage.cs
+++ b/src/Spring/Spring.Web/Web/UI/MasterPage.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.UI;
using Spring.Collections;
@@ -521,7 +522,7 @@ namespace Spring.Web.UI
///
public virtual bool Validate(object validationContext, params IValidator[] validators)
{
- IDictionary contextParams = CreateValidatorParameters();
+ IDictionary contextParams = CreateValidatorParameters();
bool result = true;
foreach (IValidator validator in validators)
{
@@ -559,9 +560,9 @@ namespace Spring.Web.UI
/// Dictionary containing parameters that should be passed to
/// the data validation framework.
///
- protected virtual IDictionary CreateValidatorParameters()
+ protected virtual IDictionary CreateValidatorParameters()
{
- IDictionary parameters = new ListDictionary();
+ IDictionary parameters = new Dictionary(8);
parameters["page"] = this.Page;
parameters["usercontrol"] = this;
parameters["session"] = this.Session;
diff --git a/src/Spring/Spring.Web/Web/UI/Page.cs b/src/Spring/Spring.Web/Web/UI/Page.cs
index edf5122a..9d27c960 100644
--- a/src/Spring/Spring.Web/Web/UI/Page.cs
+++ b/src/Spring/Spring.Web/Web/UI/Page.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
@@ -1048,7 +1049,7 @@ namespace Spring.Web.UI
///
public bool Validate( object validationContext, params IValidator[] validators )
{
- IDictionary contextParams = CreateValidatorParameters();
+ IDictionary contextParams = CreateValidatorParameters();
bool result = true;
foreach (IValidator validator in validators)
{
@@ -1091,9 +1092,9 @@ namespace Spring.Web.UI
/// Dictionary containing parameters that should be passed to
/// the data validation framework.
///
- protected virtual IDictionary CreateValidatorParameters()
+ protected virtual IDictionary CreateValidatorParameters()
{
- IDictionary parameters = new ListDictionary();
+ IDictionary parameters = new Dictionary();
parameters["page"] = this;
parameters["session"] = this.Session;
parameters["application"] = this.Application;
diff --git a/src/Spring/Spring.Web/Web/UI/UserControl.cs b/src/Spring/Spring.Web/Web/UI/UserControl.cs
index 430cb017..5423ef9b 100644
--- a/src/Spring/Spring.Web/Web/UI/UserControl.cs
+++ b/src/Spring/Spring.Web/Web/UI/UserControl.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
@@ -630,7 +631,7 @@ namespace Spring.Web.UI
///
public bool Validate( object validationContext, params IValidator[] validators )
{
- IDictionary contextParams = CreateValidatorParameters();
+ IDictionary contextParams = CreateValidatorParameters();
bool result = true;
foreach (IValidator validator in validators)
{
@@ -673,9 +674,9 @@ namespace Spring.Web.UI
/// Dictionary containing parameters that should be passed to
/// the data validation framework.
///
- protected virtual IDictionary CreateValidatorParameters()
+ protected virtual IDictionary CreateValidatorParameters()
{
- IDictionary parameters = new ListDictionary();
+ IDictionary parameters = new Dictionary(8);
parameters["page"] = this.Page;
parameters["usercontrol"] = this;
parameters["session"] = this.Session;
diff --git a/src/Spring/Spring.Web/Web/UI/Validation/AbstractValidationErrorsRenderer.cs b/src/Spring/Spring.Web/Web/UI/Validation/AbstractValidationErrorsRenderer.cs
index c4c6b5db..1285cb06 100644
--- a/src/Spring/Spring.Web/Web/UI/Validation/AbstractValidationErrorsRenderer.cs
+++ b/src/Spring/Spring.Web/Web/UI/Validation/AbstractValidationErrorsRenderer.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using Page=Spring.Web.UI.Page;
@@ -50,6 +51,6 @@ namespace Spring.Web.UI.Validation
/// Web form instance.
/// An HTML writer to use.
/// The list of validation errors.
- public abstract void RenderErrors(Page page, HtmlTextWriter writer, IList errors);
+ public abstract void RenderErrors(Page page, HtmlTextWriter writer, IList errors);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/UI/Validation/DivValidationErrorsRenderer.cs b/src/Spring/Spring.Web/Web/UI/Validation/DivValidationErrorsRenderer.cs
index be66ea6c..b64b4a41 100644
--- a/src/Spring/Spring.Web/Web/UI/Validation/DivValidationErrorsRenderer.cs
+++ b/src/Spring/Spring.Web/Web/UI/Validation/DivValidationErrorsRenderer.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using Spring.Web.UI.Validation;
using Page=Spring.Web.UI.Page;
@@ -44,7 +45,7 @@ namespace Spring.Web.UI.Validation
/// Web form instance.
/// An HTML writer to use.
/// The list of validation errors.
- public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
+ public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
{
if (CssClass != null)
{
diff --git a/src/Spring/Spring.Web/Web/UI/Validation/IValidationErrorsRenderer.cs b/src/Spring/Spring.Web/Web/UI/Validation/IValidationErrorsRenderer.cs
index 0f533f89..8a0c4bae 100644
--- a/src/Spring/Spring.Web/Web/UI/Validation/IValidationErrorsRenderer.cs
+++ b/src/Spring/Spring.Web/Web/UI/Validation/IValidationErrorsRenderer.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using Spring.Web.UI.Controls;
@@ -51,6 +52,6 @@ namespace Spring.Web.UI.Validation
/// Web form instance.
/// An HTML writer to use.
/// The list of validation errors.
- void RenderErrors(Page page, HtmlTextWriter writer, IList errors);
+ void RenderErrors(Page page, HtmlTextWriter writer, IList errors);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/UI/Validation/IconValidationErrorsRenderer.cs b/src/Spring/Spring.Web/Web/UI/Validation/IconValidationErrorsRenderer.cs
index 529793db..91f38059 100644
--- a/src/Spring/Spring.Web/Web/UI/Validation/IconValidationErrorsRenderer.cs
+++ b/src/Spring/Spring.Web/Web/UI/Validation/IconValidationErrorsRenderer.cs
@@ -18,11 +18,9 @@
#endregion
-using System.Collections;
+using System.Collections.Generic;
using System.Text;
using System.Web.UI;
-using Spring.Web.UI.Validation;
-using Page=Spring.Web.UI.Page;
namespace Spring.Web.UI.Validation
{
@@ -63,7 +61,7 @@ namespace Spring.Web.UI.Validation
/// Web form instance.
/// An HTML writer to use.
/// The list of validation errors.
- public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
+ public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
{
if (errors != null && errors.Count > 0)
{
diff --git a/src/Spring/Spring.Web/Web/UI/Validation/SpanValidationErrorsRenderer.cs b/src/Spring/Spring.Web/Web/UI/Validation/SpanValidationErrorsRenderer.cs
index 32d0dfb1..5d22bbcf 100644
--- a/src/Spring/Spring.Web/Web/UI/Validation/SpanValidationErrorsRenderer.cs
+++ b/src/Spring/Spring.Web/Web/UI/Validation/SpanValidationErrorsRenderer.cs
@@ -19,6 +19,7 @@
#endregion
using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
using Spring.Web.UI.Controls;
@@ -46,7 +47,7 @@ namespace Spring.Web.UI.Validation
/// Web form instance.
/// An HTML writer to use.
/// The list of validation errors.
- public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
+ public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors)
{
if (errors != null && errors.Count > 0)
{
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs
index 206bc5eb..82e9ae41 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs
@@ -21,8 +21,8 @@
#region Imports
using NUnit.Framework;
+
using Spring.Aop.Framework;
-using Spring.Aop.Framework.DynamicProxy;
using Spring.Context;
using Spring.Context.Support;
using Spring.Objects;
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/AdvisorAdapterRegistrationTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/AdvisorAdapterRegistrationTests.cs
index 1cce8faf..8806a520 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/AdvisorAdapterRegistrationTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/AdvisorAdapterRegistrationTests.cs
@@ -17,16 +17,14 @@
#endregion
#region Imports
-using System;
-using System.Text;
using NUnit.Framework;
-using Spring.Aop;
using Spring.Context;
using Spring.Context.Support;
using Spring.Objects;
using Spring.Objects.Factory.Xml;
+
#endregion
namespace Spring.Aop.Framework.Adapter
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/UnknownAdviceTypeExceptionTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/UnknownAdviceTypeExceptionTests.cs
index 46ca2191..b2e750c6 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/UnknownAdviceTypeExceptionTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/Adapter/UnknownAdviceTypeExceptionTests.cs
@@ -20,8 +20,6 @@
#region Imports
-using System;
-
using NUnit.Framework;
#endregion
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs
index 452ae41f..194208e5 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs
@@ -22,9 +22,11 @@
using System;
using System.Reflection;
+
using Common.Logging;
+
using NUnit.Framework;
-using Spring.Aop.Framework.DynamicProxy;
+
using Spring.Aop.Support;
using Spring.Context.Support;
using Spring.Objects;
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorTests.cs
index 972ca7e4..ca9bd976 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorTests.cs
@@ -21,7 +21,7 @@
#region Imports
using NUnit.Framework;
-using Spring.Aop.Framework.DynamicProxy;
+
using Spring.Context.Support;
using Spring.Objects;
using Spring.Objects.Factory;
diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AttributeAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AttributeAutoProxyCreatorTests.cs
index 1ebe12a8..fe22d7ef 100644
--- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AttributeAutoProxyCreatorTests.cs
+++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AttributeAutoProxyCreatorTests.cs
@@ -21,9 +21,10 @@
#region Imports
using System;
+
using NUnit.Framework;
+
using Spring.Objects;
-using Spring.Stereotype;
#endregion
diff --git a/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs
index 468e6e09..fbac52d7 100644
--- a/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs
+++ b/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using NUnit.Framework;
using Spring.Core.IO;
@@ -144,22 +145,22 @@ namespace Spring.Context.Support
return null;
}
- public IDictionary GetObjectsOfType(Type type)
+ public IDictionary GetObjectsOfType(Type type)
{
return null;
}
- public IDictionary GetObjectsOfType()
+ public IDictionary GetObjectsOfType()
{
return null;
}
- public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
return null;
}
- public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
+ public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects)
{
return null;
}
diff --git a/test/Spring/Spring.Core.Tests/Context/Support/ResourceSetMessageSourceTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/ResourceSetMessageSourceTests.cs
index 429a26a4..4fa9ea12 100644
--- a/test/Spring/Spring.Core.Tests/Context/Support/ResourceSetMessageSourceTests.cs
+++ b/test/Spring/Spring.Core.Tests/Context/Support/ResourceSetMessageSourceTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
@@ -51,7 +52,7 @@ namespace Spring.Context.Support
private const string ResourceFileName = "Spring.Context.Tests";
// The namespace is added during the build...
private const string ResourceBaseName = ResourceNamespace + "." + ResourceFileName;
- private IList resourceManagerList;
+ private IList resourceManagerList;
[TestFixtureSetUp]
public void TestFixtureSetUp()
@@ -72,7 +73,7 @@ namespace Spring.Context.Support
public void Init()
{
messageSource = new ResourceSetMessageSource();
- resourceManagerList = new ArrayList();
+ resourceManagerList = new List();
Assembly ass = this.GetType().Assembly;
resourceManagerList.Add(new ResourceManager(ResourceBaseName, ass));
}
diff --git a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs
index b6c5eb6b..733b28bc 100644
--- a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs
+++ b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Diagnostics;
using System.EnterpriseServices;
using System.Globalization;
@@ -68,10 +69,10 @@ namespace Spring.Expressions
private IExpression exp;
private object rootContext;
private object expected;
- private IDictionary variables;
+ private IDictionary variables;
public AsyncTestExpressionEvaluation(int iterations, IExpression exp, object rootContext, object expected,
- IDictionary variables)
+ IDictionary variables)
: base(iterations)
{
this.exp = exp;
@@ -296,7 +297,7 @@ namespace Spring.Expressions
[Test(Description = "http://jira.springframework.org/browse/SPRNET-944")]
public void TestDateVariableExpression()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["date"] = "2008-05-15";
object value = ExpressionEvaluator.GetValue(null, "#date", vars);
Assert.That(value, Is.EqualTo("2008-05-15"));
@@ -305,7 +306,7 @@ namespace Spring.Expressions
[Test(Description = "http://jira.springframework.org/browse/SPRNET-1155")]
public void TestDateVariableExpressionCamelCased()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["Date"] = "2008-05-15";
object value = ExpressionEvaluator.GetValue(null, "#Date", vars);
Assert.That(value, Is.EqualTo("2008-05-15"));
@@ -583,7 +584,7 @@ namespace Spring.Expressions
ExpressionEvaluator.GetValue(ieee, "Officers['advisors'][0].Inventions[2]"));
// maps with non-literal parameters
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["prez"] = "president";
Assert.AreEqual(pupin, ExpressionEvaluator.GetValue(ieee, "Officers[#prez]", vars));
@@ -651,7 +652,7 @@ namespace Spring.Expressions
{
IExpression expression = Expression.Parse("Foo(#var1)");
MethodInvokationCases testContext = new MethodInvokationCases();
- Hashtable args = new Hashtable();
+ Dictionary args = new Dictionary();
args["var1"] = "myString";
Assert.AreEqual("myString", expression.GetValue(testContext, args));
args["var1"] = 12;
@@ -891,7 +892,7 @@ namespace Spring.Expressions
[Test]
public void TestVariableNode()
{
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["newName"] = "Aleksandar Seovic";
Assert.AreEqual("Ana Maria Seovic",
ExpressionEvaluator.GetValue(null, "#newName = 'Ana Maria Seovic'", vars));
@@ -943,7 +944,7 @@ namespace Spring.Expressions
Assert.AreEqual("falseExp", ExpressionEvaluator.GetValue(null, "(false ? 'trueExp' : 'falseExp')"));
ExpressionEvaluator.SetValue(ieee, "Name", "IEEE");
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["queryName"] = "Nikola Tesla";
string expression =
@"IsMember(#queryName)
@@ -1000,7 +1001,7 @@ namespace Spring.Expressions
{
Assert.AreEqual(1 & 3, ExpressionEvaluator.GetValue(null, "1 and 3"));
Assert.AreEqual(1 & -1, ExpressionEvaluator.GetValue(null, "1 and -1"));
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["ALL"] = (RegexOptions) 0xFFFF;
Assert.AreEqual(RegexOptions.IgnoreCase, ExpressionEvaluator.GetValue(null, "T(System.Text.RegularExpressions.RegexOptions).IgnoreCase and #ALL", vars));
}
@@ -1386,7 +1387,7 @@ namespace Spring.Expressions
[ExpectedException(typeof(ArgumentException))]
public void TestComparisonOfInstancesThatDoNotImplementIComparable()
{
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["tesla"] = tesla;
vars["pupin"] = pupin;
ExpressionEvaluator.GetValue(null, "#tesla > #pupin", vars);
@@ -1419,7 +1420,7 @@ namespace Spring.Expressions
DateTime anaDOB = new DateTime(2004, 8, 14);
DateTime aleksDOB = new DateTime(1974, 8, 24);
TimeSpan diff = anaDOB - aleksDOB;
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
vars["ts"] = diff;
Assert.AreEqual(anaDOB, ExpressionEvaluator.GetValue(null, "date('1974-08-24') + #ts", vars));
@@ -1456,7 +1457,7 @@ namespace Spring.Expressions
DateTime anaDOB = new DateTime(2004, 8, 14);
DateTime aleksDOB = new DateTime(1974, 8, 24);
TimeSpan diff = anaDOB - aleksDOB;
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["ts"] = diff;
Assert.AreEqual(aleksDOB, ExpressionEvaluator.GetValue(null, "date('2004-08-14') - #ts", vars));
@@ -1714,12 +1715,12 @@ namespace Spring.Expressions
public void TestDelegateFunctionExpressions()
{
//for purposes of an example in documentation
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["sqrt"] = new DoubleFunction(Sqrt);
double result = (double)ExpressionEvaluator.GetValue(null, "#sqrt(64)", vars);
Assert.AreEqual(8, result);
- vars = new Hashtable();
+ vars = new Dictionary();
vars["max"] = new DoubleFunctionTwoArgs(Max);
result = (double) ExpressionEvaluator.GetValue(null, "#max(5,25)", vars);
Assert.AreEqual(25, result);
@@ -1751,25 +1752,25 @@ namespace Spring.Expressions
// simple function
Assert.AreEqual(4,
- ExpressionEvaluator.GetValue(null, "(#add = {|x, y| $x + $y}; #add(2, 2))", new Hashtable()));
+ ExpressionEvaluator.GetValue(null, "(#add = {|x, y| $x + $y}; #add(2, 2))", new Dictionary()));
Assert.AreEqual(25,
ExpressionEvaluator.GetValue(null, "(#max = {|x, y| $x > $y ? $x : $y }; #max(5,25))",
- new Hashtable()));
+ new Dictionary()));
// recursive function
Assert.AreEqual(120,
ExpressionEvaluator.GetValue(null,
"(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(5))",
- new Hashtable()));
+ new Dictionary()));
// function invoked within projection expression
string expr = "(#upper = {|txt| $txt.ToUpper() }; !{ #upper(Name) })";
- IList upperNames = (IList)ExpressionEvaluator.GetValue(ieee.Members, expr, new Hashtable());
+ IList upperNames = (IList)ExpressionEvaluator.GetValue(ieee.Members, expr, new Dictionary());
Assert.AreEqual("NIKOLA TESLA", upperNames[0]);
Assert.AreEqual("MIHAJLO PUPIN", upperNames[1]);
// function that delegates to a function passed as a parameter
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
Expression.RegisterFunction("sqrt", "{|n| Math.Sqrt($n)}", vars);
Expression.RegisterFunction("fact", "{|n| $n <= 1 ? 1 : $n * #fact($n-1)}", vars);
string expr2 =
@@ -1788,7 +1789,7 @@ namespace Spring.Expressions
Assert.AreEqual(120,
ExpressionEvaluator.GetValue(null,
"(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #f = #fact; #f(5))",
- new Hashtable()));
+ new Dictionary()));
}
#region Collection Processor and Aggregator tests
@@ -1806,7 +1807,7 @@ namespace Spring.Expressions
public void TestCustomCollectionProcessor()
{
// Test for the purposes of creating documentation example.
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["EvenSum"] = new IntEvenSumCollectionProcessor();
Assert.AreEqual(6, ExpressionEvaluator.GetValue(null, "{1, 2, 3, 4}.EvenSum()", vars));
@@ -2043,7 +2044,7 @@ namespace Spring.Expressions
[Test]
public void TestSetValue()
{
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["tesla"] = tesla;
vars["pupin"] = pupin;
ExpressionEvaluator.SetValue(null, "#tesla.Name", vars, "Tesla, Nikola");
@@ -2204,7 +2205,7 @@ namespace Spring.Expressions
[Test]
public void TestMethodResolutionResolvesToExactMatchOfArgumentTypes()
{
- Hashtable args = new Hashtable();
+ Dictionary args = new Dictionary();
args["bars"] = new Bar[] { new Bar() };
Foo foo = new Foo();
@@ -2218,7 +2219,7 @@ namespace Spring.Expressions
[Test]
public void TestIndexerResolutionResolvesToExactMatchOfArgumentTypes()
{
- Hashtable args = new Hashtable();
+ Dictionary args = new Dictionary();
args["bars"] = new Bar[] { new Bar() };
Foo foo = new Foo();
@@ -2234,7 +2235,7 @@ namespace Spring.Expressions
public void TestCtorResolutionResolvesToExactMatchOfArgumentTypes()
{
TypeRegistry.RegisterType(typeof(Foo));
- Hashtable args = new Hashtable();
+ Dictionary args = new Dictionary();
args["bars"] = new Bar[] { new Bar() };
// ensure noone changed our test class
@@ -2454,8 +2455,8 @@ namespace Spring.Expressions
IExpression exp2 = Expression.Parse("(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(#root))");
- AsyncTestTask t4 = new AsyncTestExpressionEvaluation(2000, exp2, 5, 120, new Hashtable()).Start();
- AsyncTestTask t5 = new AsyncTestExpressionEvaluation(2000, exp2, 6, 720, new Hashtable()).Start();
+ AsyncTestTask t4 = new AsyncTestExpressionEvaluation(2000, exp2, 5, 120, new Dictionary()).Start();
+ AsyncTestTask t5 = new AsyncTestExpressionEvaluation(2000, exp2, 6, 720, new Dictionary()).Start();
t1.AssertNoException();
t2.AssertNoException();
@@ -2538,12 +2539,12 @@ namespace Spring.Expressions
// case #root != #this in Projection - ToString() will be applied to #this
exp = Expression.Parse("(ToString(); #noop ={|val| $val}; !{#noop(ToString()) } )");
- result = exp.GetValue(new int[] { 100, 200 }, new Hashtable());
+ result = exp.GetValue(new int[] { 100, 200 }, new Dictionary());
Assert.AreEqual(new string[] { "100", "200" }, result);
// case #root != #this in Selection - ToString() will be applied to #this
exp = Expression.Parse("(#noop ={|val| $val}; ?{#noop(ToString()=='100')} )");
- result = exp.GetValue(new int[] { 100, 200 }, new Hashtable());
+ result = exp.GetValue(new int[] { 100, 200 }, new Dictionary());
IList list = new ArrayList();
list.Add(100);
Assert.AreEqual(list, result);
@@ -2772,7 +2773,7 @@ namespace Spring.Expressions
{
int n = 10000000;
object x = "";
- IDictionary vars = new Hashtable();
+ IDictionary vars = new Dictionary();
// tesla.PlaceOfBirth
start = DateTime.Now;
diff --git a/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs b/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
index 430d85f1..fa071237 100644
--- a/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
+++ b/test/Spring/Spring.Core.Tests/Expressions/FunctionNodeTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Threading;
using NUnit.Framework;
using Spring.Collections;
@@ -40,7 +41,7 @@ namespace Spring.Expressions
[Test]
public void ExecutesLambdaFunction()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
Expression.RegisterFunction("ident", "{|n| $n}", vars);
FunctionNode fn = new FunctionNode();
@@ -56,7 +57,7 @@ namespace Spring.Expressions
[Test]
public void ExecutesDelegate()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["concat"] = new TestCallback(Concat);
FunctionNode fn = new FunctionNode();
@@ -83,7 +84,7 @@ namespace Spring.Expressions
[Test, Explicit]
public void ExecutesDelegatePerformance()
{
- Hashtable vars = new Hashtable(5);
+ Dictionary vars = new Dictionary(5);
WaitCallback noop = delegate (object arg)
{
// noop
diff --git a/test/Spring/Spring.Core.Tests/Expressions/MethodNodeTests.cs b/test/Spring/Spring.Core.Tests/Expressions/MethodNodeTests.cs
index 12cfea8e..121b42b2 100644
--- a/test/Spring/Spring.Core.Tests/Expressions/MethodNodeTests.cs
+++ b/test/Spring/Spring.Core.Tests/Expressions/MethodNodeTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using NUnit.Framework;
using Spring.Expressions.Processors;
@@ -47,7 +48,7 @@ namespace Spring.Expressions
[Test]
public void CallCustomCollectionProcessor()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["myCollProc"] = new MyTestCollectionProcessor();
MethodNode mn = new MethodNode();
diff --git a/test/Spring/Spring.Core.Tests/Expressions/Processors/OrderByProcessorTests.cs b/test/Spring/Spring.Core.Tests/Expressions/Processors/OrderByProcessorTests.cs
index 976eefaa..b9331f18 100644
--- a/test/Spring/Spring.Core.Tests/Expressions/Processors/OrderByProcessorTests.cs
+++ b/test/Spring/Spring.Core.Tests/Expressions/Processors/OrderByProcessorTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using NUnit.Framework;
#endregion
@@ -52,7 +53,7 @@ namespace Spring.Expressions.Processors
Assert.AreEqual(new object[] { 1, 2.0, "a", 'b' }, exp.GetValue(input));
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
Expression.RegisterFunction( "compare", "{|a,b| $a.ToString().CompareTo($b.ToString())}", vars);
exp = Expression.Parse("orderBy(#compare)");
Assert.AreEqual(new object[] { 1, 2.0, "a", 'b' }, exp.GetValue(input, vars));
@@ -61,7 +62,7 @@ namespace Spring.Expressions.Processors
[Test]
public void OrderByDelegate()
{
- Hashtable vars = new Hashtable();
+ Dictionary vars = new Dictionary();
vars["compare"] = new CompareCallback(CompareObjects);
IExpression exp = Expression.Parse("orderBy(#compare)");
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
index d00689a7..d21006ac 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using NUnit.Framework;
namespace Spring.Objects.Factory.Config
@@ -15,7 +16,7 @@ namespace Spring.Objects.Factory.Config
dvs.Add("key1", "theValue");
dvs.Add("key2", "theValue");
- foreach (DictionaryEntry dv in dvs)
+ foreach (KeyValuePair dv in dvs)
{
Assert.AreEqual("theValue", dv.Value);
}
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
index 45e29993..6457253e 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
@@ -145,7 +146,7 @@ namespace Spring.Objects.Factory
def.FactoryMethodName = "CreateTestObject";
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
lof.RegisterObjectDefinition("factoryObject", def);
- IDictionary objs = lof.GetObjectsOfType(typeof(TestObject));
+ IDictionary objs = lof.GetObjectsOfType();
Assert.AreEqual(1, objs.Count);
}
@@ -159,7 +160,7 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
lof.RegisterObjectDefinition("factoryObject", def);
lof.RegisterObjectDefinition("target", new RootObjectDefinition(typeof(TestObjectCreator)));
- IDictionary objs = lof.GetObjectsOfType(typeof(TestObject));
+ IDictionary objs = lof.GetObjectsOfType();
Assert.AreEqual(1, objs.Count);
}
@@ -171,7 +172,7 @@ namespace Spring.Objects.Factory
= new RootObjectDefinition(typeof(TestGenericObject));
def.FactoryMethodName = "CreateList";
lof.RegisterObjectDefinition("foo", def);
- IDictionary objs = lof.GetObjectsOfType(typeof(System.Collections.Generic.List));
+ IDictionary objs = lof.GetObjectsOfType(typeof(List));
Assert.AreEqual(1, objs.Count);
}
@@ -185,7 +186,7 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
lof.RegisterObjectDefinition("factoryObject", def);
lof.RegisterObjectDefinition("target", new RootObjectDefinition(typeof(TestGenericObject)));
- IDictionary objs = lof.GetObjectsOfType(typeof(TestGenericObject));
+ IDictionary objs = lof.GetObjectsOfType(typeof(TestGenericObject));
Assert.AreEqual(1, objs.Count);
}
@@ -223,7 +224,7 @@ namespace Spring.Objects.Factory
typeof(StaticFactoryMethodObject));
def.FactoryMethodName = "CreateObject";
lof.RegisterObjectDefinition("foo", def);
- IDictionary objs = lof.GetObjectsOfType(typeof(DBNull));
+ IDictionary objs = lof.GetObjectsOfType(typeof(DBNull));
Assert.AreEqual(1, objs.Count,
"Must be looking at the RETURN TYPE of the factory method, " +
"and hence get one DBNull object back.");
@@ -592,10 +593,10 @@ namespace Spring.Objects.Factory
TestObject test = (TestObject)lof.GetObject("test");
Assert.AreEqual(singletonObject, lof.GetObject("singletonObject"));
Assert.AreEqual(singletonObject, test.Spouse);
- Hashtable objectsOfType = (Hashtable)lof.GetObjectsOfType(typeof(TestObject), false, true);
+ IDictionary objectsOfType = lof.GetObjectsOfType(typeof(TestObject), false, true);
Assert.AreEqual(2, objectsOfType.Count);
- Assert.IsTrue(objectsOfType.ContainsValue(test));
- Assert.IsTrue(objectsOfType.ContainsValue(singletonObject));
+ Assert.IsTrue(objectsOfType.Values.Contains(test));
+ Assert.IsTrue(objectsOfType.Values.Contains(singletonObject));
}
[Test]
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs
index 84cf65cf..c3471d00 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using NUnit.Framework;
using Rhino.Mocks;
using Spring.Objects.Factory.Config;
@@ -183,7 +184,7 @@ namespace Spring.Objects.Factory
object test = _factory.GetObject("test");
object testFactory1 = _factory.GetObject("testFactory1");
- IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof (ITestObject), true, false);
+ IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof (ITestObject), true, false);
Assert.AreEqual(3, objects.Count);
Assert.AreEqual(test3, objects["test3"]);
Assert.AreEqual(test, objects["test"]);
@@ -228,7 +229,7 @@ namespace Spring.Objects.Factory
DefaultListableObjectFactory child = new DefaultListableObjectFactory(root);
child.RegisterObjectDefinition("excludeLocalObject", new RootObjectDefinition(typeof(Hashtable)));
- IDictionary objectEntries = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(child, typeof(ArrayList), true, true);
+ IDictionary objectEntries = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(child, typeof(ArrayList), true, true);
// "excludeLocalObject" matches on the parent, but not the local object definition
Assert.AreEqual(0, objectEntries.Count);
}
@@ -238,7 +239,7 @@ namespace Spring.Objects.Factory
{
StaticListableObjectFactory lof = new StaticListableObjectFactory();
lof.AddObject("foo", new object());
- IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(lof, typeof (ITestObject), true, false);
+ IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(lof, typeof (ITestObject), true, false);
Assert.IsTrue(objects.Count == 0);
}
@@ -257,7 +258,7 @@ namespace Spring.Objects.Factory
t3.AfterPropertiesSet(); // StaticListableObjectFactory does support lifecycle calls.
lof.AddObject("t4", t4);
t4.AfterPropertiesSet(); // StaticListableObjectFactory does support lifecycle calls.
- IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(lof, typeof(ITestObject), true, false);
+ IDictionary objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(lof, typeof(ITestObject), true, false);
Assert.AreEqual(2, objects.Count);
Assert.AreEqual(t1, objects["t1"]);
Assert.AreEqual(t2, objects["t2"]);
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
index daf513af..65674bee 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
@@ -786,10 +787,10 @@ namespace Spring.Objects.Factory.Xml
// abstract objects should not match
//TODO add overloaded GetObjectOfType with 1 arg
- IDictionary tbs = parent.GetObjectsOfType(typeof(TestObject), true, true);
+ IDictionary tbs = parent.GetObjectsOfType(typeof(TestObject), true, true);
Assert.AreEqual(2, tbs.Count);
- Assert.IsTrue(tbs.Contains("inheritedTestObjectPrototype"));
- Assert.IsTrue(tbs.Contains("inheritedTestObjectSingleton"));
+ Assert.IsTrue(tbs.ContainsKey("inheritedTestObjectPrototype"));
+ Assert.IsTrue(tbs.ContainsKey("inheritedTestObjectSingleton"));
// non-abstract object should work, even if it serves as parent
object o1 = parent.GetObject("inheritedTestObjectPrototype");
diff --git a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs
index 426e18cf..ce159cd4 100644
--- a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs
+++ b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs
@@ -22,6 +22,8 @@
using System;
using System.Collections;
+using System.Collections.Generic;
+
using NUnit.Framework;
#endregion
@@ -214,71 +216,71 @@ namespace Spring.Util
[Test]
public void GetAntExpressionsWithNull()
{
- IList actual = StringUtils.GetAntExpressions(null);
+ IList actual = StringUtils.GetAntExpressions(null);
Assert.IsNotNull(actual);
string[] expected = new string[] {};
- Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) ArrayList.Adapter(actual).ToArray(typeof (string))));
+ Assert.IsTrue(ArrayUtils.AreEqual(expected, new List(actual).ToArray()));
}
[Test]
public void GetAntExpressionsWithEmptyString()
{
- IList actual = StringUtils.GetAntExpressions(String.Empty);
+ IList actual = StringUtils.GetAntExpressions(String.Empty);
Assert.IsNotNull(actual);
string[] expected = new string[] {};
- Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) ArrayList.Adapter(actual).ToArray(typeof (string))));
+ Assert.IsTrue(ArrayUtils.AreEqual(expected, new List(actual).ToArray()));
}
[Test]
public void GetAntExpressionsWithAStringThatDoesntHaveAnyExpressions()
{
- IList actual = StringUtils.GetAntExpressions("I could really go a cup of tea right now... in fact I think I'll go get one.");
+ IList actual = StringUtils.GetAntExpressions("I could really go a cup of tea right now... in fact I think I'll go get one.");
Assert.IsNotNull(actual);
string[] expected = new string[] {};
- Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) ArrayList.Adapter(actual).ToArray(typeof (string))));
+ Assert.IsTrue(ArrayUtils.AreEqual(expected, new List(actual).ToArray()));
}
[Test]
public void GetAntExpressionsWithAValidExpression()
{
- IList actual = StringUtils.GetAntExpressions("${slurp}. Ah! That is one good cup of tea. That agent Cooper and his coffee... he sure was missing out on a good thing.");
+ IList actual = StringUtils.GetAntExpressions("${slurp}. Ah! That is one good cup of tea. That agent Cooper and his coffee... he sure was missing out on a good thing.");
CheckGetAntExpressions(actual, "slurp");
}
[Test]
public void GetAntExpressionsWithANestedExpression()
{
- IList actual = StringUtils.GetAntExpressions("And yeah, I've never been a fan of the doughnut... ${blechh${shudder}}");
+ IList actual = StringUtils.GetAntExpressions("And yeah, I've never been a fan of the doughnut... ${blechh${shudder}}");
CheckGetAntExpressions(actual, "blechh${shudder");
}
[Test]
public void GetAntExpressionsWithACoupleOfDuplicatedValidExpressions()
{
- IList actual = StringUtils.GetAntExpressions("${sigh}. Laura Palmer though... man, that sure was a tragedy. ${sigh}");
+ IList actual = StringUtils.GetAntExpressions("${sigh}. Laura Palmer though... man, that sure was a tragedy. ${sigh}");
CheckGetAntExpressions(actual, "sigh");
}
[Test]
public void GetAntExpressionsWithACoupleOfUniqueValidExpressions()
{
- IList actual = StringUtils.GetAntExpressions("${Mmm}. Has there been any good telly since then... ${thinks}");
+ IList actual = StringUtils.GetAntExpressions("${Mmm}. Has there been any good telly since then... ${thinks}");
CheckGetAntExpressions(actual, "Mmm", "thinks");
}
[Test]
public void GetAntExpressionsWithMalformedExpression()
{
- IList actual = StringUtils.GetAntExpressions("Mmm... just what counts as ${a malformed{ expression?");
+ IList actual = StringUtils.GetAntExpressions("Mmm... just what counts as ${a malformed{ expression?");
CheckGetAntExpressions(actual, new string[] {});
}
- private static void CheckGetAntExpressions(IList actual, params string[] expected)
+ private static void CheckGetAntExpressions(IList actual, params string[] expected)
{
Assert.IsNotNull(actual);
Assert.IsTrue(ArrayUtils.AreEqual(
expected,
- (string[]) ArrayList.Adapter(actual).ToArray(typeof (string))));
+ new List(actual).ToArray()));
}
[Test]
diff --git a/test/Spring/Spring.Core.Tests/Validation/Actions/ExceptionActionTests.cs b/test/Spring/Spring.Core.Tests/Validation/Actions/ExceptionActionTests.cs
index 54711cc3..fbc9eb1d 100644
--- a/test/Spring/Spring.Core.Tests/Validation/Actions/ExceptionActionTests.cs
+++ b/test/Spring/Spring.Core.Tests/Validation/Actions/ExceptionActionTests.cs
@@ -20,7 +20,7 @@
using System;
using System.Collections;
-
+using System.Collections.Generic;
using NUnit.Framework;
using Spring.Expressions;
@@ -39,7 +39,7 @@ namespace Spring.Validation.Actions
public void WhenInvalidThrowDefaultException()
{
Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary();
ExceptionAction action = new ExceptionAction();
try
{
@@ -56,7 +56,7 @@ namespace Spring.Validation.Actions
public void WhenInvalidThrowCustomException()
{
Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
- IDictionary vars = new Hashtable();
+ Dictionary vars = new Dictionary