Introducing generics

This commit is contained in:
Marko Lahma
2012-03-24 12:12:16 +02:00
parent 6f789061aa
commit 05de414adc
224 changed files with 1319 additions and 1245 deletions

View File

@@ -18,7 +18,6 @@
#endregion
using System;
using Spring.Objects.Factory.Xml;
namespace Spring.Aop.Config

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using Spring.Objects.Factory.Config;
#endregion

View File

@@ -21,12 +21,10 @@
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using AopAlliance.Aop;
using AopAlliance.Intercept;
using Spring.Aop;
using Spring.Aop.Support;
#endregion
@@ -43,7 +41,7 @@ namespace Spring.Aop.Framework.Adapter
[Serializable]
public class DefaultAdvisorAdapterRegistry : IAdvisorAdapterRegistry
{
private readonly IList adapters = new ArrayList();
private readonly IList<IAdvisorAdapter> adapters = new List<IAdvisorAdapter>();
/// <summary>
/// Creates a new instance of the

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Aop;
using AopAlliance.Intercept;

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Intercept;
#endregion

View File

@@ -20,16 +20,16 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using AopAlliance.Aop;
using AopAlliance.Intercept;
using Spring.Aop;
using Spring.Aop.Support;
using Spring.Aop.Target;
using Spring.Util;
using Spring.Proxy;
namespace Spring.Aop.Framework
{
@@ -65,7 +65,7 @@ namespace Spring.Aop.Framework
/// will be wrapped in an advice before being added to this list.
/// </p>
/// </remarks>
private IList _advisors = new ArrayList();
private List<IAdvisor> _advisors = new List<IAdvisor>();
/// <summary>
/// Array updated on changes to the advisors list, which is easier to
@@ -76,7 +76,7 @@ namespace Spring.Aop.Framework
/// <summary>
/// List of introductions.
/// </summary>
private ArrayList _introductions = new ArrayList();
private List<IIntroductionAdvisor> _introductions = new List<IIntroductionAdvisor>();
/// <summary>
/// Interface map specifying which object should interface methods be
@@ -88,7 +88,7 @@ namespace Spring.Aop.Framework
/// to the target object.
/// </p>
/// </remarks>
private readonly IDictionary interfaceMap = new ListDictionary();
private readonly Dictionary<Type, IIntroductionAdvisor> interfaceMap = new Dictionary<Type, IIntroductionAdvisor>();
/// <summary>
/// The <see cref="Spring.Aop.ITargetSource"/> for this instance.
@@ -108,7 +108,7 @@ namespace Spring.Aop.Framework
/// <summary>
/// The list of <see cref="Spring.Aop.Framework.AdvisedSupport"/> event listeners.
/// </summary>
private readonly IList listeners = new ArrayList();
private readonly IList<IAdvisedSupportListener> listeners = new List<IAdvisedSupportListener>();
/// <summary>
/// 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
/// </param>
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<IAdvisor>(other.Advisors), new List<IAdvisor>(other.Introductions));
}
/// <summary>
@@ -1515,7 +1514,7 @@ namespace Spring.Aop.Framework
/// <param name="targetSource">the new target source</param>
/// <param name="advisors">the advisors for the chain</param>
/// <param name="introductions">the introductions for the chain</param>
protected internal virtual void CopyConfigurationFrom(AdvisedSupport other, ITargetSource targetSource, IList advisors, IList introductions)
protected internal virtual void CopyConfigurationFrom(AdvisedSupport other, ITargetSource targetSource, IList<IAdvisor> advisors, IList<IAdvisor> 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<IAdvisor>();
foreach (IAdvisor advisor in advisors)
{
AssertUtils.ArgumentNotNull(advisor, "Advisor must not be null");
AddAdvisor(advisor);
}
this._introductions = new ArrayList();
this._introductions = new List<IIntroductionAdvisor>();
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)

View File

@@ -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
/// <see cref="AopAlliance.Intercept.IMethodInterceptor"/> (if there's
/// a dynamic method matcher that needs evaluation at runtime).
/// </returns>
public static IList CalculateInterceptors(
public static IList<object> CalculateInterceptors(
IAdvised config, object proxy, MethodInfo method, Type targetType)
{
IList interceptors = new ArrayList(config.Advisors.Length);
IList<object> interceptors = new List<object>(config.Advisors.Length);
foreach (IAdvisor advisor in config.Advisors)
{
if (advisor is IPointcutAdvisor)

View File

@@ -22,7 +22,6 @@
using System;
using System.Collections;
using Spring.Threading;
#endregion

View File

@@ -21,8 +21,8 @@
#region Imports
using System;
using System.Collections;
using System.Reflection;
using Spring.Collections;
using Spring.Util;

View File

@@ -22,8 +22,9 @@
using System;
using System.Collections;
using Common.Logging;
using Spring.Aop.Framework.DynamicProxy;
using Spring.Core;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;

View File

@@ -20,10 +20,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Remoting;
using AopAlliance.Aop;
using Common.Logging;
using Spring.Aop.Framework.Adapter;
using Spring.Aop.Target;
using Spring.Collections;
@@ -31,7 +35,6 @@ using Spring.Core;
using Spring.Objects;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Util;
namespace Spring.Aop.Framework.AutoProxy
{
@@ -583,7 +586,7 @@ namespace Spring.Aop.Framework.AutoProxy
private IAdvisor[] ResolveInterceptorNames()
{
ArrayList advisors = new ArrayList();
List<IAdvisor> advisors = new List<IAdvisor>();
foreach (string name in interceptorNames)
{
object next = owningObjectFactory.GetObject(name);
@@ -596,7 +599,7 @@ namespace Spring.Aop.Framework.AutoProxy
advisors.Add(advisorAdapterRegistry.Wrap(next));
}
}
return (IAdvisor[])advisors.ToArray(typeof(IAdvisor));
return advisors.ToArray();
}
#endregion

View File

@@ -21,9 +21,6 @@
#region Imports
using System;
using System.Collections;
using Spring.Objects.Factory;
using Spring.Util;
#endregion

View File

@@ -21,8 +21,7 @@
#region Imports
using System;
using System.Collections;
using Spring.Aop.Support;
using Spring.Util;
#endregion

View File

@@ -22,7 +22,7 @@
using System;
using System.Collections;
using Spring.Context;
using Spring.Objects.Factory;
#endregion

View File

@@ -22,14 +22,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using AopAlliance.Aop;
using Spring.Util;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Aop;
using Spring.Aop.Framework;
using Spring.Aop.Framework.Adapter;
using Spring.Aop.Framework.DynamicProxy;
using Spring.Core;
@@ -309,7 +309,7 @@ namespace Spring.Aop.Framework.AutoProxy
private IAdvisor[] ResolveInterceptorNames()
{
ArrayList advisors = new ArrayList();
List<IAdvisor> advisors = new List<IAdvisor>();
foreach (string name in interceptorNames)
{
object next = objectFactory.GetObject(name);
@@ -322,7 +322,7 @@ namespace Spring.Aop.Framework.AutoProxy
advisors.Add(advisorAdapterRegistry.Wrap(next));
}
}
return (IAdvisor[])advisors.ToArray(typeof(IAdvisor));
return advisors.ToArray();
}
#endregion

View File

@@ -20,6 +20,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Common.Logging;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
@@ -66,7 +68,7 @@ namespace Spring.Aop.Framework.AutoProxy
{
string[] advisorNames = GetAdvisorCandidateNames(targetType, targetName);
ArrayList advisors = new ArrayList();
List<IAdvisor> advisors = new List<IAdvisor>();
if (advisorNames.Length == 0)
{
@@ -111,12 +113,12 @@ namespace Spring.Aop.Framework.AutoProxy
/// </summary>
/// <param name="advisors">the advisor list</param>
/// <param name="advisorName">the object name of the advisor to add</param>
private void AddAdvisorCandidate(ArrayList advisors, string advisorName)
private void AddAdvisorCandidate(List<IAdvisor> 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<string> candidateNameList = new List<string>();
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();
}
}
}

View File

@@ -21,8 +21,7 @@
#region Imports
using System;
using System.Collections;
using Spring.Objects.Factory;
using Spring.Util;
#endregion

View File

@@ -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<IAdvisor> thisAdvisors = new List<IAdvisor>(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)
)
)
{

View File

@@ -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
/// <summary>
/// Optimization fields
/// </summary>
private static IList EmptyList = ArrayList.ReadOnly(new ArrayList());
private static IList<object> EmptyList = new ReadOnlyCollection<object>(new object[0]);
/// <summary>
/// IAdvised delegate
@@ -214,7 +216,7 @@ namespace Spring.Aop.Framework.DynamicProxy
/// <param name="targetType">target type</param>
/// <param name="method">target method</param>
/// <returns>list of inteceptors for the specified method</returns>
public IList GetInterceptors(Type targetType, MethodInfo method)
public IList<object> GetInterceptors(Type targetType, MethodInfo method)
{
if (m_advised.Advisors.Length == 0)
{

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;

View File

@@ -22,7 +22,6 @@
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
#endregion

View File

@@ -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;

View File

@@ -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;

View File

@@ -20,11 +20,8 @@
#region Imports
using System;
using System.Reflection;
using System.Reflection.Emit;
using Spring.Util;
using Spring.Proxy;
#endregion

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Reflection.Emit;
using Spring.Proxy;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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<MethodInfo, IList<object>> methodCache = new Dictionary<MethodInfo, IList<object>>();
/// <summary>
/// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
@@ -59,10 +57,10 @@ namespace Spring.Aop.Framework
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
/// instances for the supplied <paramref name="proxy"/>.
/// </returns>
public IList GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType)
public IList<object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType)
{
IList cached = (IList)this.methodCache[method];
if (cached == null)
IList<object> cached;
if (!this.methodCache.TryGetValue(method, out cached))
{
// recalculate...
cached = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType);

View File

@@ -24,7 +24,7 @@ using System;
using System.Collections;
using AopAlliance.Aop;
using Spring.Aop;
using Spring.Proxy;
#endregion

View File

@@ -18,8 +18,6 @@
#endregion
using System;
namespace Spring.Aop.Framework
{
/// <summary>

View File

@@ -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
/// <author>Aleksandar Seovic (.NET)</author>
public interface IAdvisorChainFactory : IAdvisedSupportListener
{
/// <summary>
/// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
/// instances for the supplied <paramref name="proxy"/>.
/// </summary>
/// <param name="advised">The proxy configuration object.</param>
/// <param name="proxy">The object proxy.</param>
/// <param name="method">
/// The method for which the interceptors are to be evaluated.
/// </param>
/// <param name="targetType">
/// The <see cref="System.Type"/> of the target object.
/// </param>
/// <returns>
/// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
/// instances for the supplied <paramref name="proxy"/>.
/// </returns>
IList GetInterceptors(
IAdvised advised, object proxy, MethodInfo method, Type targetType);
/// <summary>
/// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
/// instances for the supplied <paramref name="proxy"/>.
/// </summary>
/// <param name="advised">The proxy configuration object.</param>
/// <param name="proxy">The object proxy.</param>
/// <param name="method">
/// The method for which the interceptors are to be evaluated.
/// </param>
/// <param name="targetType">
/// The <see cref="System.Type"/> of the target object.
/// </param>
/// <returns>
/// The list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
/// <see cref="Spring.Aop.Framework.InterceptorAndDynamicMethodMatcher"/>
/// instances for the supplied <paramref name="proxy"/>.
/// </returns>
IList<object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType);
}
}

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using Spring.Proxy;
#endregion

View File

@@ -18,8 +18,6 @@
#endregion
using System;
namespace Spring.Aop.Framework
{
/// <summary>

View File

@@ -18,8 +18,6 @@
#endregion
using System;
namespace Spring.Aop.Framework
{
/// <summary>

View File

@@ -19,8 +19,8 @@
#endregion
using System;
using AopAlliance.Intercept;
using Spring.Aop;
namespace Spring.Aop.Framework
{

View File

@@ -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;

View File

@@ -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<IAdvisor> advisorChain = FreshAdvisorChain();
IList<IAdvisor> 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<object> objects = new List<object>();
Dictionary<object, string> names = new Dictionary<object, string>();
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<object, string> names = new Dictionary<object, string>();
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.
/// </summary>
private IList FreshAdvisorChain()
private IList<IAdvisor> FreshAdvisorChain()
{
IAdvisor[] advisors = Advisors;
ArrayList freshAdvisors = new ArrayList();
List<IAdvisor> freshAdvisors = new List<IAdvisor>();
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.
/// </summary>
private IList FreshIntroductionChain()
private IList<IAdvisor> FreshIntroductionChain()
{
IIntroductionAdvisor[] introductions = Introductions;
ArrayList freshIntroductions = new ArrayList();
List<IAdvisor> freshIntroductions = new List<IAdvisor>();
foreach (IIntroductionAdvisor introduction in introductions)
{
if (introduction is PrototypePlaceholder)

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Aop;
#endregion

View File

@@ -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
/// <value>
/// A list of advisors.
/// </value>
IList Advisors { get; set; }
IList<IAdvisor> Advisors { get; set; }
}
}

View File

@@ -20,8 +20,8 @@
#region Imports
using System;
using System.Reflection;
using AopAlliance.Aop;
#endregion

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Aop;
#endregion

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Reflection;
#endregion

View File

@@ -18,12 +18,6 @@
#endregion
#region Imports
using System;
#endregion
namespace Spring.Aop
{
/// <summary>

View File

@@ -18,12 +18,6 @@
#endregion
#region Imports
using System;
#endregion
namespace Spring.Aop
{
/// <summary>

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Aop;
#endregion

View File

@@ -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

View File

@@ -21,8 +21,9 @@
#region Imports
using System;
using AopAlliance.Aop;
using Spring.Core;
using Spring.Util;
#endregion

View File

@@ -19,7 +19,6 @@
#endregion
using System;
using System.Reflection;
namespace Spring.Aop.Support
{

View File

@@ -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

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using AopAlliance.Intercept;
#endregion

View File

@@ -18,12 +18,6 @@
#endregion
#region Imports
using System;
#endregion
namespace Spring.Aop.Target
{
/// <summary>

View File

@@ -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;

View File

@@ -9,12 +9,6 @@
#endregion
#region Imports
using System;
#endregion
namespace AopAlliance.Aop
{
/// <summary>

View File

@@ -9,12 +9,6 @@
#endregion
#region Imports
using System;
#endregion
namespace AopAlliance.Intercept
{
/// <summary>

View File

@@ -11,7 +11,6 @@
#region Imports
using System;
using AopAlliance.Aop;
#endregion

View File

@@ -9,12 +9,6 @@
#endregion
#region Imports
using System;
#endregion
namespace AopAlliance.Intercept
{
/// <summary>

View File

@@ -9,12 +9,6 @@
#endregion
#region Imports
using System;
#endregion
namespace AopAlliance.Intercept
{
/// <summary>

View File

@@ -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
/// <summary>
/// Determines whether this instance can handle the exception the specified exception.
/// </summary>
@@ -138,7 +137,7 @@ namespace Spring.Aspects
/// <returns>
/// <c>true</c> if this instance can handle the specified exception; otherwise, <c>false</c>.
/// </returns>
public bool CanHandleException(Exception ex, IDictionary callContextDictionary)
public bool CanHandleException(Exception ex, IDictionary<string, object> callContextDictionary)
{
if (SourceExceptionNames != null)
{
@@ -176,7 +175,7 @@ namespace Spring.Aspects
/// Handles the exception.
/// </summary>
/// <returns>The return value from handling the exception, if not rethrown or a new exception is thrown.</returns>
public abstract object HandleException(IDictionary callContextDictionary);
public abstract object HandleException(IDictionary<string, object> callContextDictionary);
#endregion
}

View File

@@ -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
/// <returns>
/// A dictionary containing all method arguments, keyed by method name.
/// </returns>
protected static IDictionary PrepareVariables(MethodInfo method, object[] arguments)
protected static IDictionary<string, object> PrepareVariables(MethodInfo method, object[] arguments)
{
IDictionary vars = new Hashtable();
IDictionary<string, object> vars = new Dictionary<string, object>();
vars[method.Name] = method;
@@ -141,7 +143,7 @@ namespace Spring.Aspects.Cache
/// If the SpEL expression could not be successfuly resolved to a boolean.
/// </exception>
protected static bool EvalCondition(string condition,
IExpression conditionExpression, object context, IDictionary variables)
IExpression conditionExpression, object context, IDictionary<string, object> variables)
{
if (conditionExpression == null)
{

View File

@@ -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
/// <value>
/// A list of advisors for this aspect.
/// </value>
public IList Advisors
public IList<IAdvisor> Advisors
{
get { return advisors; }
set { throw new NotSupportedException("Cache aspect advisors cannot be set externally."); }

View File

@@ -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<string, object> vars = PrepareVariables(method, arguments);
for (int i = 0; i < cacheParameterAttributes.Length; i++)
{
foreach (CacheParameterAttribute paramInfo in cacheParameterAttributes[i])

View File

@@ -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<string, object> 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
/// <returns>
/// Return value for the specified <paramref name="invocation"/>.
/// </returns>
private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, IDictionary vars, out bool cacheHit)
private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, IDictionary<string, object> vars, out bool cacheHit)
{
if (resultInfo != null)
{
@@ -258,7 +259,7 @@ namespace Spring.Aspects.Cache
/// <param name="vars">
/// Variables for expression evaluation.
/// </param>
private void CacheResultItems(IEnumerable items, CacheResultItemsAttribute[] itemInfoArray, IDictionary vars)
private void CacheResultItems(IEnumerable items, CacheResultItemsAttribute[] itemInfoArray, IDictionary<string, object> vars)
{
foreach (CacheResultItemsAttribute itemInfo in itemInfoArray)
{

View File

@@ -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<string, object> 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
{

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using Spring.Aop.Support;
using Spring.Caching;
using Spring.Context;

View File

@@ -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
/// <returns>The output of <see cref="IExceptionHandler.HandleException"/> </returns>
protected virtual object InvokeHandlers(Exception ex, IMethodInvocation invocation)
{
IDictionary callContextDictionary = new Hashtable();
Dictionary<string, object> callContextDictionary = new Dictionary<string, object>();
callContextDictionary.Add("method", invocation.Method);
callContextDictionary.Add("args", invocation.Arguments);
callContextDictionary.Add("target", invocation.Target);

View File

@@ -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.
/// </summary>
/// <returns>The return value from handling the exception, if not rethrown or a new exception is thrown.</returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
try
{

View File

@@ -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
/// <returns>
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
/// </returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
//TODO log name is targettype.
ILog adviceLogger = LogManager.GetLogger(logName);

View File

@@ -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.
/// </summary>
/// <returns>The return value from handling the exception, if not rethrown or a new exception is thrown.</returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
object returnVal = null;
try

View File

@@ -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.
/// </summary>
/// <returns>The return value from handling the exception, if not rethrown or a new exception is thrown.</returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
return "swallow";
}

View File

@@ -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.
/// </summary>
/// <returns>The return value from handling the exception, if not rethrown or a new exception is thrown.</returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
object o = null;
try {

View File

@@ -20,6 +20,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Spring.Aspects
{
@@ -37,7 +38,7 @@ namespace Spring.Aspects
/// <returns>
/// <c>true</c> if this instance can handle the specified exception; otherwise, <c>false</c>.
/// </returns>
bool CanHandleException(Exception ex, IDictionary callContextDictionary);
bool CanHandleException(Exception ex, IDictionary<string, object> callContextDictionary);
/// <summary>
/// Handles the exception.
@@ -46,7 +47,7 @@ namespace Spring.Aspects
/// <returns>
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
/// </returns>
object HandleException(IDictionary callContextDictionary);
object HandleException(IDictionary<string, object> callContextDictionary);
/// <summary>
/// Gets the source exception names.

View File

@@ -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
/// throws an exception.
/// </exception>
public override object Invoke(IMethodInvocation invocation)
{
{
IDictionary<string, object> callContextDictionary = new Dictionary<string, object>();
callContextDictionary.Add("method", invocation.Method);
callContextDictionary.Add("args", invocation.Arguments);
@@ -195,7 +198,7 @@ namespace Spring.Aspects
log.Debug("Invoked successfully after " + numAttempts + " attempt(s)");
return returnVal;
}
private static void Sleep(RetryExceptionHandler handler, IDictionary<string, object> callContextDictionary, SleepHandler sleepHandler)
{
if (handler.IsDelayBased)

View File

@@ -19,7 +19,7 @@
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
namespace Spring.Aspects
{
@@ -119,7 +119,7 @@ namespace Spring.Aspects
/// <returns>
/// The return value from handling the exception, if not rethrown or a new exception is thrown.
/// </returns>
public override object HandleException(IDictionary callContextDictionary)
public override object HandleException(IDictionary<string, object> callContextDictionary)
{
return null;
}

View File

@@ -1,4 +1,3 @@
using System;
using System.Reflection;
[assembly: AssemblyTitle("Spring.Aop")]

View File

@@ -59,13 +59,13 @@ namespace Spring.Caching
/// </param>
void Remove(object key);
/// <summary>
/// Removes collection of items from the cache.
/// </summary>
/// <param name="keys">
/// Collection of keys to remove.
/// </param>
void RemoveAll(ICollection keys);
/// <summary>
/// Removes collection of items from the cache.
/// </summary>
/// <param name="keys">
/// Collection of keys to remove.
/// </param>
void RemoveAll(ICollection keys);
/// <summary>
/// Removes all items from the cache.

View File

@@ -20,6 +20,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Spring.Caching
{
@@ -30,7 +31,8 @@ namespace Spring.Caching
/// <author>Aleksandar Seovic</author>
public class NonExpiringCache : AbstractCache
{
private readonly IDictionary itemStore = new Hashtable();
private readonly object syncRoot = new object();
private readonly IDictionary<object, object> itemStore = new Dictionary<object, object>();
/// <summary>
/// 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
/// </returns>
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
/// </param>
public override void Remove(object key)
{
lock (itemStore.SyncRoot)
lock (syncRoot)
{
itemStore.Remove(key);
}
@@ -99,7 +103,7 @@ namespace Spring.Caching
/// </param>
public override void RemoveAll(ICollection keys)
{
lock (itemStore.SyncRoot)
lock (syncRoot)
{
foreach (object key in keys)
{
@@ -113,7 +117,7 @@ namespace Spring.Caching
/// </summary>
public override void Clear()
{
lock (itemStore.SyncRoot)
lock (syncRoot)
{
itemStore.Clear();
}
@@ -133,7 +137,7 @@ namespace Spring.Caching
/// </param>
protected override void DoInsert(object key, object value, TimeSpan timeToLive)
{
lock (itemStore.SyncRoot)
lock (syncRoot)
{
itemStore[key] = value;
}

View File

@@ -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<IObjectFactoryPostProcessor> _objectFactoryPostProcessors;
private readonly IList<IObjectPostProcessor> _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<IObjectFactoryPostProcessor>();
_defaultObjectPostProcessors = new List<IObjectPostProcessor>();
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<string> processedObjects = new HashSet<string>();
if (objectFactory is IObjectDefinitionRegistry)
{
IObjectDefinitionRegistry registry = (IObjectDefinitionRegistry)objectFactory;
ArrayList regularPostProcessors = new ArrayList();
ArrayList registryPostProcessors = new ArrayList();
List<IObjectFactoryPostProcessor> regularPostProcessors = new List<IObjectFactoryPostProcessor>();
List<IObjectDefinitionRegistryPostProcessor> registryPostProcessors = new List<IObjectDefinitionRegistryPostProcessor>();
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<string, IObjectDefinitionRegistryPostProcessor> objectMap = objectFactory.GetObjectsOfType<IObjectDefinitionRegistryPostProcessor>(true, false);
ArrayList registryPostProcessorObjects = new ArrayList(objectMap.Values);
List<IObjectDefinitionRegistryPostProcessor> registryPostProcessorObjects = new List<IObjectDefinitionRegistryPostProcessor>(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<string, IObjectDefinitionRegistryPostProcessor> 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<string> factoryProcessorNames = new List<string>();
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<IObjectFactoryPostProcessor> priorityOrderedFactoryProcessors = new List<IObjectFactoryPostProcessor>();
List<string> orderedFactoryProcessorsNames = new List<string>();
List<string> nonOrderedFactoryProcessorNames = new List<string>();
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<IObjectFactoryPostProcessor>(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<IObjectFactoryPostProcessor> orderedFactoryProcessors = new List<IObjectFactoryPostProcessor>();
foreach (string orderedFactoryProcessorsName in orderedFactoryProcessorsNames)
{
orderedFactoryProcessors.Add(ObjectFactory.GetObject(orderedFactoryProcessorsName,
typeof(IObjectFactoryPostProcessor)));
orderedFactoryProcessors.Add(ObjectFactory.GetObject<IObjectFactoryPostProcessor>(orderedFactoryProcessorsName));
}
orderedFactoryProcessors.Sort(new OrderComparator());
InvokeObjectFactoryPostProcessors(orderedFactoryProcessors, ObjectFactory);
// and then the unordered ones...
ArrayList nonOrderedPostProcessors = new ArrayList();
List<IObjectFactoryPostProcessor> nonOrderedPostProcessors = new List<IObjectFactoryPostProcessor>();
foreach (string nonOrderedFactoryProcessorName in nonOrderedFactoryProcessorNames)
{
nonOrderedPostProcessors.Add(ObjectFactory.GetObject(nonOrderedFactoryProcessorName,
typeof(IObjectFactoryPostProcessor)));
nonOrderedPostProcessors.Add(ObjectFactory.GetObject<IObjectFactoryPostProcessor>(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<string> factoryProcessorNames, List<IObjectFactoryPostProcessor> 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<IObjectFactoryPostProcessor>(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<string, IObjectPostProcessor> dict = GetObjectsOfType<IObjectPostProcessor>(true, false);
List<IObjectPostProcessor> objectProcessors = new List<IObjectPostProcessor>(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<IEventRegistryAware> interestedParties = GetObjectsOfType<IEventRegistryAware>(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<IApplicationEventListener> listeners = GetObjectsOfType<IApplicationEventListener>(true, false).Values;
foreach (IApplicationEventListener applicationListener in listeners)
{
EventRegistry.Subscribe(applicationListener);
@@ -883,7 +880,7 @@ namespace Spring.Context.Support
/// <see cref="Spring.Objects.Factory.Config.IObjectFactoryPostProcessor"/>s
/// that will be applied to the objects created with this factory.
/// </value>
private IList ObjectFactoryPostProcessors
private IList<IObjectFactoryPostProcessor> 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
/// </remarks>
public void Start()
{
IDictionary lifecycleObjects = LifeCycleObjects;
foreach (DictionaryEntry dictionaryEntry in lifecycleObjects)
IDictionary<string, ILifecycle> lifecycleObjects = LifeCycleObjects;
foreach (KeyValuePair<string, ILifecycle> 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
/// </remarks>
public void Stop()
{
IDictionary lifecycleObjects = LifeCycleObjects;
foreach (DictionaryEntry dictionaryEntry in lifecycleObjects)
IDictionary<string, ILifecycle> lifecycleObjects = LifeCycleObjects;
foreach (KeyValuePair<string, ILifecycle> 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<string, ILifecycle> lifecycleObjects = LifeCycleObjects;
foreach (KeyValuePair<string, ILifecycle> 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.
/// </summary>
/// <value>A dictionary of ILifecycle objects with object name as key.</value>
private IDictionary LifeCycleObjects
private IDictionary<string, ILifecycle> LifeCycleObjects
{
get
{
IConfigurableListableObjectFactory objectFactory = ObjectFactory;
string[] objectNames = objectFactory.SingletonNames;
IDictionary lifeCycleObjects = new Hashtable();
IDictionary<string, ILifecycle> lifeCycleObjects = new Dictionary<string, ILifecycle>();
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.
/// </exception>
/// <seealso cref="Spring.Objects.Factory.IListableObjectFactory.GetObjectsOfType(Type)"/>
public IDictionary GetObjectsOfType(Type type)
public IDictionary<string, object> GetObjectsOfType(Type type)
{
return GetObjectsOfType(type, true, true);
}
@@ -1445,9 +1442,9 @@ namespace Spring.Context.Support
/// <exception cref="Spring.Objects.ObjectsException">
/// If the objects could not be created.
/// </exception>
public IDictionary GetObjectsOfType<T>()
public IDictionary<string, T> GetObjectsOfType<T>()
{
return GetObjectsOfType(typeof(T));
return (IDictionary<string, T>) GetObjectsOfType(typeof(T));
}
/// <summary>
@@ -1477,7 +1474,7 @@ namespace Spring.Context.Support
/// If the objects could not be created.
/// </exception>
/// <seealso cref="Spring.Objects.Factory.IListableObjectFactory.GetObjectsOfType(Type, bool, bool)"/>
public IDictionary GetObjectsOfType(
public IDictionary<string, object> GetObjectsOfType(
Type type, bool includePrototypes, bool includeFactoryObjects)
{
return ObjectFactory.GetObjectsOfType(type, includePrototypes, includeFactoryObjects);
@@ -1494,12 +1491,12 @@ namespace Spring.Context.Support
/// The <see cref="System.Type"/> (class or interface) to match.
/// </typeparam>
/// <param name="includePrototypes">
/// Whether to include prototype objects too or just singletons (also applies to
/// <see cref="Spring.Objects.Factory.IFactoryObject"/>s).
/// Whether to include prototype objects too or just singletons (also applies to
/// <see cref="Spring.Objects.Factory.IFactoryObject"/>s).
/// </param>
/// <param name="includeFactoryObjects">
/// Whether to include <see cref="Spring.Objects.Factory.IFactoryObject"/>s too
/// or just normal objects.
/// Whether to include <see cref="Spring.Objects.Factory.IFactoryObject"/>s too
/// or just normal objects.
/// </param>
/// <returns>
/// A <see cref="System.Collections.IDictionary"/> of the matching objects,
@@ -1509,9 +1506,9 @@ namespace Spring.Context.Support
/// <exception cref="Spring.Objects.ObjectsException">
/// If the objects could not be created.
/// </exception>
public IDictionary GetObjectsOfType<T>(bool includePrototypes, bool includeFactoryObjects)
public IDictionary<string, T> GetObjectsOfType<T>(bool includePrototypes, bool includeFactoryObjects)
{
return GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects);
return ObjectFactory.GetObjectsOfType<T>(includePrototypes, includeFactoryObjects);
}
/// <summary>

View File

@@ -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;

View File

@@ -18,7 +18,6 @@
#endregion
using System;
using Spring.Core.IO;
namespace Spring.Context.Support

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Runtime.Remoting;
using Spring.Objects.Factory.Config;

View File

@@ -21,7 +21,7 @@
#region Imports
using System;
using System.Globalization;
using Spring.Objects;
#endregion

View File

@@ -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.
/// </summary>
private string[] GetResources( XmlElement contextElement )
{
ArrayList resourceNodes = new ArrayList(contextElement.ChildNodes.Count);
{
List<string> resourceNodes = new List<string>(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();
}
/// <summary>
/// Returns the array of child contexts for this context.
/// </summary>
private XmlNode[] GetChildContexts(XmlElement contextElement)
{
ArrayList contextNodes = new ArrayList(contextElement.ChildNodes.Count);
{
List<XmlNode> contextNodes = new List<XmlNode>(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

View File

@@ -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<string, IApplicationContext> contextMap = new Dictionary<string, IApplicationContext>(StringComparer.OrdinalIgnoreCase);
#region Constructor (s) / Destructor
@@ -108,7 +106,7 @@ namespace Spring.Context.Support
{
IApplicationContext parent = context.ParentContext;
Hashtable contexts = new Hashtable();
Dictionary<int, IApplicationContext> contexts = new Dictionary<int, IApplicationContext>();
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<IApplicationContext> contexts = new List<IApplicationContext>(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;
}
}

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Globalization;
#endregion

View File

@@ -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<string, object> _cachedResources;
private IList<object> _resourceManagers;
#endregion
@@ -60,15 +60,15 @@ namespace Spring.Context.Support
/// </summary>
public ResourceSetMessageSource()
{
_cachedResources = new Hashtable();
_resourceManagers = new ArrayList();
_cachedResources = new Dictionary<string, object>();
_resourceManagers = new List<object>();
}
/// <summary>
/// The collection of <see cref="System.Resources.ResourceManager"/>s
/// in this <see cref="Spring.Context.Support.ResourceSetMessageSource"/>.
/// </summary>
public IList ResourceManagers
public IList<object> 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)

View File

@@ -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
/// <seealso cref="Spring.Context.Support.DelegatingMessageSource"/>
public class StaticMessageSource : AbstractMessageSource
{
private Hashtable _messages;
private Hashtable _objects;
private Dictionary<string, string> _messages;
private Dictionary<string, object> _objects;
/// <summary>
/// Creates a new instance of the
@@ -56,8 +56,8 @@ namespace Spring.Context.Support
/// </summary>
public StaticMessageSource()
{
_messages = new Hashtable();
_objects = new Hashtable();
_messages = new Dictionary<string, string>();
_objects = new Dictionary<string, object>();
}
/// <summary>
@@ -73,11 +73,14 @@ namespace Spring.Context.Support
/// </returns>
/// <seealso cref="Spring.Context.Support.AbstractMessageSource.ResolveMessage(string, CultureInfo)"/>
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;
}
/// <summary>
/// <summary>
/// Resolves an object (typically an icon or bitmap).
/// </summary>
/// <param name="code">The code of the object to resolve.</param>
@@ -91,7 +94,10 @@ namespace Spring.Context.Support
/// <seealso cref="Spring.Context.Support.AbstractMessageSource.ResolveObject(string, CultureInfo)"/>
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;
}

View File

@@ -18,7 +18,6 @@
#endregion
using System;
using Spring.Core.IO;
namespace Spring.Context.Support

View File

@@ -21,6 +21,7 @@
#region Imports
using System.Collections;
using System.Collections.Generic;
using Spring.Core;
#endregion
@@ -52,7 +53,7 @@ namespace Spring.Core
/// </param>
public ComposedCriteria(ICriteria criteria)
{
_criteria = new ArrayList();
_criteria = new List<ICriteria>();
Add(criteria);
}
@@ -102,14 +103,14 @@ namespace Spring.Core
/// The list of <see cref="Spring.Core.ICriteria"/> composing this
/// instance.
/// </summary>
protected IList Criteria
protected IList<ICriteria> Criteria
{
get { return _criteria; }
}
#region Fields
private IList _criteria;
private IList<ICriteria> _criteria;
#endregion
}

View File

@@ -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<string> expressions = StringUtils.GetAntExpressions(path);
foreach (string expression in expressions)
{
string environmentValue

View File

@@ -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
/// </summary>
private const string ResourcesSectionName = "spring/resourceHandlers";
private static IDictionary resourceHandlers = new Hashtable();
private static object syncRoot = new object();
private static IDictionary<string, IDynamicConstructor> resourceHandlers = new Dictionary<string, IDynamicConstructor>();
/// <summary>
/// Registers standard and user-configured resource handlers.
/// </summary>
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;
}
/// <summary>
@@ -153,7 +156,7 @@ namespace Spring.Core.IO
/// <exception cref="ArgumentNullException">If <paramref name="protocolName"/> is <c>null</c>.</exception>
public static bool IsHandlerRegistered(string protocolName)
{
return resourceHandlers.Contains(protocolName);
return resourceHandlers.ContainsKey(protocolName);
}
/// <summary>
@@ -241,7 +244,7 @@ namespace Spring.Core.IO
#endregion
lock (resourceHandlers.SyncRoot)
lock (syncRoot)
{
SecurityCritical.ExecutePrivileged( new SecurityPermission(SecurityPermissionFlag.Infrastructure), delegate
{

View File

@@ -22,27 +22,46 @@
using System;
using System.Collections;
using System.Collections.Generic;
#endregion
namespace Spring.Core
{
/// <summary>
/// Comparator implementation for <see cref="Spring.Core.IOrdered"/> objects, sorting by
/// order value ascending (resp. by priority descending).
/// </summary>
/// <remarks>
/// <p>
/// Non-<see cref="Spring.Core.IOrdered"/> 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
/// <see cref="Spring.Core.IOrdered"/> objects).
/// </p>
/// </remarks>
/// <author>Juergen Hoeller</author>
/// <summary>
/// Comparator implementation for <see cref="Spring.Core.IOrdered"/> objects, sorting by
/// order value ascending (resp. by priority descending).
/// </summary>
/// <remarks>
/// <p>
/// Non-<see cref="Spring.Core.IOrdered"/> 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
/// <see cref="Spring.Core.IOrdered"/> objects).
/// </p>
/// </remarks>
/// <author>Juergen Hoeller</author>
/// <author>Aleksandar Seovic (.Net)</author>
[Serializable]
public class OrderComparator : IComparer
{
public class OrderComparator : OrderComparator<object>, IComparer
{
}
/// <summary>
/// Comparator implementation for <see cref="Spring.Core.IOrdered"/> objects, sorting by
/// order value ascending (resp. by priority descending).
/// </summary>
/// <remarks>
/// <p>
/// Non-<see cref="Spring.Core.IOrdered"/> 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
/// <see cref="Spring.Core.IOrdered"/> objects).
/// </p>
/// </remarks>
/// <author>Juergen Hoeller</author>
/// <author>Aleksandar Seovic (.Net)</author>
[Serializable]
public class OrderComparator<T> : IComparer<T>
{
/// <summary>
/// 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
/// <returns>
/// -1 if first object is less then second, 1 if it is greater, or 0 if they are equal.
/// </returns>
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);
}
}
}
/// <summary>
/// Handle the case when both objects have equal sort order priority. By default returns 0,
@@ -87,9 +106,9 @@ namespace Spring.Core
/// <returns>
/// -1 if first object is less then second, 1 if it is greater, or 0 if they are equal.
/// </returns>
protected virtual int CompareEqualOrder(object o1, object o2)
protected virtual int CompareEqualOrder(T o1, T o2)
{
return 0;
}
}
}
}
}

View File

@@ -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
/// </summary>
private const string TypeConvertersSectionName = "spring/typeConverters";
private static IDictionary converters = new Hashtable();
private static readonly object syncRoot = new object();
private static IDictionary<Type, TypeConverter> converters = new Dictionary<Type, TypeConverter>();
/// <summary>
/// Registers standard and configured type converters.
/// </summary>
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;
}

View File

@@ -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<string, Type> types = new Dictionary<string, Type>();
#endregion
@@ -441,7 +441,7 @@ namespace Spring.Core.TypeResolution
/// </summary>
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;
}
/// <summary>
@@ -674,7 +676,7 @@ namespace Spring.Core.TypeResolution
/// </returns>
public static bool ContainsAlias(string alias)
{
return types.Contains(alias);
return types.ContainsKey(alias);
}
}
}

View File

@@ -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<Type> interfaces = new List<Type>();
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

View File

@@ -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<ErrorMessage> 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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public abstract void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
public abstract void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables);
/// <summary>
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public abstract void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
public abstract void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables);
/// <summary>
/// Sets error message that should be displayed in the case

View File

@@ -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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> 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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
protected virtual void DoBindSourceToTarget(object source, object target, IDictionary variables)
protected virtual void DoBindSourceToTarget(object source, object target, IDictionary<string, object> 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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> 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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
protected virtual void DoBindTargetToSource(object source, object target, IDictionary variables)
protected virtual void DoBindTargetToSource(object source, object target, IDictionary<string, object> 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.
/// </summary>
/// <param name="source">
/// Source object to extract value from.
/// Source object to extract value from.
/// </param>
/// <param name="variables">
/// Variables for expression evaluation.
/// Variables for expression evaluation.
/// </param>
/// <returns>
/// The source value for the binding.
/// </returns>
protected abstract object GetSourceValue(object source, IDictionary variables);
protected abstract object GetSourceValue(object source, IDictionary<string, object> variables);
/// <summary>
/// Sets the source value for the binding.
/// </summary>
/// <param name="source">
/// The source object to set the value on.
/// The source object to set the value on.
/// </param>
/// <param name="value">
/// The value to set.
/// The value to set.
/// </param>
/// <param name="variables">
/// Variables for expression evaluation.
/// Variables for expression evaluation.
/// </param>
protected abstract void SetSourceValue(object source, object value, IDictionary variables);
protected abstract void SetSourceValue(object source, object value, IDictionary<string, object> variables);
/// <summary>
/// Gets the target value for the binding.
/// </summary>
/// <param name="target">
/// Source object to extract value from.
/// Source object to extract value from.
/// </param>
/// <param name="variables">
/// Variables for expression evaluation.
/// Variables for expression evaluation.
/// </param>
/// <returns>
/// The target value for the binding.
/// </returns>
protected abstract object GetTargetValue(object target, IDictionary variables);
protected abstract object GetTargetValue(object target, IDictionary<string, object> variables);
/// <summary>
/// Sets the target value for the binding.
/// </summary>
/// <param name="target">
/// The target object to set the value on.
/// The target object to set the value on.
/// </param>
/// <param name="value">
/// The value to set.
/// The value to set.
/// </param>
/// <param name="variables">
/// Variables for expression evaluation.
/// Variables for expression evaluation.
/// </param>
protected abstract void SetTargetValue(object target, object value, IDictionary variables);
protected abstract void SetTargetValue(object target, object value, IDictionary<string, object> variables);
#endregion
}

View File

@@ -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<IBinding> bindings = new List<IBinding>();
#endregion
@@ -34,7 +35,7 @@ namespace Spring.DataBinding
/// <value>
/// A list of bindings for this container.
/// </value>
protected IList Bindings
protected IList<IBinding> Bindings
{
get { return bindings; }
}
@@ -182,19 +183,18 @@ namespace Spring.DataBinding
/// Binds source object to target object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public virtual void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public virtual void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
foreach (IBinding binding in bindings)
{
@@ -223,19 +223,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public virtual void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public virtual void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
foreach (IBinding binding in bindings)
{

View File

@@ -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.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary variables);
void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables);
/// <summary>
/// Binds target object to source object.
@@ -58,18 +59,18 @@ namespace Spring.DataBinding
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary variables);
void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables);
/// <summary>
/// Sets error message that should be displayed in the case

View File

@@ -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");
/// <summary>
/// Binds source object to target object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public override void BindSourceToTarget(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
if (variables == null)
{
variables = new Hashtable();
variables = new Dictionary<string, object>();
}
variables["source"] = source;
variables["target"] = target;
@@ -47,23 +47,22 @@ namespace Spring.DataBinding
/// Binds target object to source object.
/// </summary>
/// <param name="source">
/// The source object.
/// The source object.
/// </param>
/// <param name="target">
/// The target object.
/// The target object.
/// </param>
/// <param name="validationErrors">
/// Validation errors collection that type conversion errors should be added to.
/// Validation errors collection that type conversion errors should be added to.
/// </param>
/// <param name="variables">
/// Variables that should be used during expression evaluation.
/// Variables that should be used during expression evaluation.
/// </param>
public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors,
IDictionary variables)
public override void BindTargetToSource(object source, object target, IValidationErrors validationErrors, IDictionary<string, object> variables)
{
if (variables == null)
{
variables = new Hashtable();
variables = new Dictionary<string, object>();
}
variables["source"] = source;
variables["target"] = target;

Some files were not shown because too many files have changed in this diff Show More