From 05de414adc16956003b81c16e6ac1b75deaa7fe0 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 24 Mar 2012 12:12:16 +0200 Subject: [PATCH 1/4] Introducing generics --- .../Aop/Config/AopNamespaceParser.cs | 1 - .../AdvisorAdapterRegistrationManager.cs | 1 - .../Adapter/DefaultAdvisorAdapterRegistry.cs | 6 +- .../Aop/Framework/Adapter/IAdvisorAdapter.cs | 1 - .../Adapter/IAdvisorAdapterRegistry.cs | 1 - .../Aop/Framework/AdvisedSupport.cs | 37 +++--- .../Aop/Framework/AdvisorChainFactoryUtils.cs | 8 +- .../Spring.Aop/Aop/Framework/AopContext.cs | 1 - .../Spring.Aop/Aop/Framework/AopUtils.cs | 2 +- .../AbstractAdvisorAutoProxyCreator.cs | 3 +- .../AutoProxy/AbstractAutoProxyCreator.cs | 9 +- .../AbstractFilteringAutoProxyCreator.cs | 3 - .../AutoProxy/AttributeAutoProxyCreator.cs | 3 +- .../DefaultAdvisorAutoProxyCreator.cs | 2 +- .../InheritanceBasedAopConfigurer.cs | 8 +- .../ObjectFactoryAdvisorRetrievalHelper.cs | 12 +- .../PointcutFilteringAutoProxyCreator.cs | 3 +- .../DynamicProxy/AbstractAopProxyFactory.cs | 7 +- .../Framework/DynamicProxy/AdvisedProxy.cs | 6 +- .../DynamicProxy/BaseAopProxyMethodBuilder.cs | 1 - .../DynamicProxy/BaseCompositionAopProxy.cs | 1 - .../CompositionAopProxyTypeBuilder.cs | 2 +- .../DecoratorAopProxyTypeBuilder.cs | 2 +- .../IAdvisedProxyMethodBuilder.cs | 3 - .../DynamicProxy/IAopProxyTypeGenerator.cs | 1 - .../InheritanceAopProxyTypeBuilder.cs | 2 +- .../IntroductionProxyMethodBuilder.cs | 3 - .../TargetAopProxyMethodBuilder.cs | 3 - .../HashtableCachingAdvisorChainFactory.cs | 14 +-- .../Spring.Aop/Aop/Framework/IAdvised.cs | 2 +- .../Aop/Framework/IAdvisedSupportListener.cs | 2 - .../Aop/Framework/IAdvisorChainFactory.cs | 41 +++--- .../Spring.Aop/Aop/Framework/IAopProxy.cs | 2 - .../Aop/Framework/IAopProxyFactory.cs | 2 - .../Spring.Aop/Aop/Framework/ITargetAware.cs | 2 - .../InterceptorAndDynamicMethodMatcher.cs | 2 +- .../Spring.Aop/Aop/Framework/ProxyConfig.cs | 4 +- .../Aop/Framework/ProxyFactoryObject.cs | 27 ++-- src/Spring/Spring.Aop/Aop/IAdvisor.cs | 1 - src/Spring/Spring.Aop/Aop/IAdvisors.cs | 6 +- .../Spring.Aop/Aop/IAfterReturningAdvice.cs | 2 +- src/Spring/Spring.Aop/Aop/IBeforeAdvice.cs | 1 - .../Spring.Aop/Aop/IMethodBeforeAdvice.cs | 1 - src/Spring/Spring.Aop/Aop/IPointcut.cs | 6 - src/Spring/Spring.Aop/Aop/IPointcutAdvisor.cs | 6 - src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs | 1 - ...AbstractRegularExpressionMethodPointcut.cs | 4 +- .../Support/NameMatchMethodPointcutAdvisor.cs | 3 +- .../Support/StaticMethodMatcherPointcut.cs | 1 - .../Target/AbstractPrototypeTargetSource.cs | 4 +- .../Target/IThreadLocalTargetSourceStats.cs | 1 - .../Spring.Aop/Aop/Target/PoolingConfig.cs | 6 - .../Aop/Target/ThreadLocalTargetSource.cs | 3 +- .../Spring.Aop/AopAlliance/Aop/IAdvice.cs | 6 - .../Intercept/IConstructorInterceptor.cs | 6 - .../AopAlliance/Intercept/IInterceptor.cs | 1 - .../AopAlliance/Intercept/IInvocation.cs | 6 - .../Intercept/IMethodInterceptor.cs | 6 - .../Aspects/AbstractExceptionHandler.cs | 7 +- .../Aspects/Cache/BaseCacheAdvice.cs | 10 +- .../Spring.Aop/Aspects/Cache/CacheAspect.cs | 5 +- .../Aspects/Cache/CacheParameterAdvice.cs | 6 +- .../Aspects/Cache/CacheResultAdvice.cs | 11 +- .../Aspects/Cache/InvalidateCacheAdvice.cs | 6 +- .../Aspects/Cache/InvalidateCacheAdvisor.cs | 1 - .../Exceptions/ExceptionHandlerAdvice.cs | 8 +- .../Exceptions/ExecuteSpelExceptionHandler.cs | 5 +- .../Aspects/Exceptions/LogExceptionHandler.cs | 6 +- .../Exceptions/ReturnValueExceptionHandler.cs | 6 +- .../Exceptions/SwallowExceptionHandler.cs | 4 +- .../Exceptions/TranslationExceptionHandler.cs | 6 +- .../Spring.Aop/Aspects/IExceptionHandler.cs | 5 +- src/Spring/Spring.Aop/Aspects/RetryAdvice.cs | 25 ++-- .../Aspects/RetryExceptionHandler.cs | 4 +- src/Spring/Spring.Aop/AssemblyInfo.cs | 1 - src/Spring/Spring.Core/Caching/ICache.cs | 14 +-- .../Spring.Core/Caching/NonExpiringCache.cs | 24 ++-- .../Support/AbstractApplicationContext.cs | 117 +++++++++--------- .../Support/AbstractXmlApplicationContext.cs | 3 +- .../AbstractXmlApplicationContextArgs.cs | 1 - .../ApplicationContextAwareProcessor.cs | 1 - .../Support/ApplicationObjectSupport.cs | 2 +- .../Context/Support/ContextHandler.cs | 19 ++- .../Context/Support/ContextRegistry.cs | 38 +++--- .../Context/Support/MessageSourceAccessor.cs | 1 - .../Support/ResourceSetMessageSource.cs | 16 +-- .../Context/Support/StaticMessageSource.cs | 26 ++-- .../Support/XmlApplicationContextArgs.cs | 1 - .../Spring.Core/Core/ComposedCriteria.cs | 7 +- .../Spring.Core/Core/IO/ResourceConverter.cs | 4 +- .../Core/IO/ResourceHandlerRegistry.cs | 17 +-- .../Spring.Core/Core/OrderComparator.cs | 67 ++++++---- .../TypeConversion/TypeConverterRegistry.cs | 15 +-- .../Core/TypeResolution/TypeRegistry.cs | 20 +-- .../TypeResolution/TypeResolutionUtils.cs | 5 +- .../DataBinding/AbstractBinding.cs | 23 ++-- .../DataBinding/AbstractSimpleBinding.cs | 67 +++++----- .../DataBinding/BaseBindingContainer.cs | 27 ++-- .../Spring.Core/DataBinding/IBinding.cs | 21 ++-- .../Spring.Core/DataBinding/ListBinding.cs | 29 +++-- .../DataBinding/SimpleExpressionBinding.cs | 29 ++--- .../Spring.Core/Expressions/BaseNode.cs | 9 +- .../Expressions/ConstructorNode.cs | 5 +- .../Spring.Core/Expressions/Expression.cs | 3 +- .../Expressions/ExpressionEvaluator.cs | 8 +- .../Spring.Core/Expressions/IExpression.cs | 5 +- .../Spring.Core/Expressions/IndexerNode.cs | 3 +- .../Spring.Core/Expressions/MethodNode.cs | 13 +- .../Expressions/NodeWithArguments.cs | 9 +- .../Processors/OrderByProcessor.cs | 5 +- .../Globalization/AbstractLocalizer.cs | 9 +- .../Globalization/AbstractResourceCache.cs | 9 +- .../Globalization/IResourceCache.cs | 5 +- .../Localizers/ResourceSetLocalizer.cs | 6 +- .../Globalization/NullResourceCache.cs | 5 +- .../Objects/Events/Support/EventRegistry.cs | 7 +- .../RequiredAttributeObjectPostProcessor.cs | 10 +- .../Config/CommandLineArgsVariableSource.cs | 13 +- .../Config/ConnectionStringsVariableSource.cs | 14 ++- .../Config/ConstructorArgumentValues.cs | 37 +++--- .../Config/DictionaryVariableSource.cs | 22 ++-- .../Objects/Factory/Config/EventValues.cs | 32 ++--- .../Factory/Config/ObjectDefinitionVisitor.cs | 51 ++++---- .../Objects/Factory/IListableObjectFactory.cs | 61 ++++----- .../Objects/Factory/ObjectFactoryUtils.cs | 27 ++-- .../AbstractAutowireCapableObjectFactory.cs | 27 ++-- .../Support/AbstractObjectDefinition.cs | 5 +- .../Factory/Support/AbstractObjectFactory.cs | 34 ++--- .../Objects/Factory/Support/AutowireUtils.cs | 5 +- .../Factory/Support/ConstructorResolver.cs | 10 +- .../Support/DefaultListableObjectFactory.cs | 112 ++++++++--------- .../Support/ObjectDefinitionBuilder.cs | 9 +- .../Support/ObjectDefinitionValueResolver.cs | 19 ++- .../Support/StaticListableObjectFactory.cs | 40 +++--- .../Factory/Xml/NamespaceParserSupport.cs | 8 +- .../Xml/ObjectDefinitionParserHelper.cs | 23 ++-- .../Factory/Xml/ObjectsNamespaceParser.cs | 3 +- .../Objects/MutablePropertyValues.cs | 5 +- .../Spring.Core/Objects/ObjectWrapper.cs | 6 +- .../Objects/Support/MethodInvoker.cs | 10 +- .../Proxy/AbstractProxyTypeBuilder.cs | 47 +++---- .../Reflection/Dynamic/DynamicConstructor.cs | 8 +- .../Reflection/Dynamic/DynamicField.cs | 8 +- .../Reflection/Dynamic/DynamicProperty.cs | 10 +- .../Dynamic/DynamicReflectionManager.cs | 46 ++++--- src/Spring/Spring.Core/Util/EventUtils.cs | 18 ++- .../Spring.Core/Util/ReflectionUtils.cs | 54 ++++---- src/Spring/Spring.Core/Util/StringUtils.cs | 11 +- .../Validation/Actions/ErrorMessageAction.cs | 8 +- .../Validation/Actions/ExceptionAction.cs | 3 +- .../Validation/Actions/ExpressionAction.cs | 6 +- .../Validation/AnyValidatorGroup.cs | 5 +- .../Validation/BaseSimpleValidator.cs | 5 +- .../Validation/BaseValidationAction.cs | 10 +- .../Spring.Core/Validation/BaseValidator.cs | 12 +- .../Validation/BaseValidatorGroup.cs | 7 +- .../Validation/CollectionValidator.cs | 7 +- .../Config/ValidationNamespaceParser.cs | 8 +- .../Validation/ExclusiveValidatorGroup.cs | 5 +- .../Validation/IValidationAction.cs | 4 +- .../Validation/IValidationErrors.cs | 7 +- .../Spring.Core/Validation/IValidator.cs | 7 +- .../Validation/ValidationErrors.cs | 57 +++++---- .../Spring.Core/Validation/ValidatorGroup.cs | 5 +- .../Validation/ValidatorReference.cs | 4 +- .../NHibernate/LocalSessionFactoryObject.cs | 16 +-- .../Data/NHibernate/SessionHolder.cs | 46 ++++--- ...sistenceExceptionTranslationInterceptor.cs | 5 +- .../Nms/Connections/CachedSession.cs | 4 +- .../Connections/ChainedExceptionListener.cs | 10 +- .../Adapter/MessageListenerAdapter.cs | 3 +- .../Core/DefaultMessageQueueFactory.cs | 7 +- .../Core/MessageQueueMetadataCache.cs | 7 +- .../Listener/MessageListenerAdapter.cs | 3 +- ...ctDependencyInjectionSpringContextTests.cs | 7 +- .../Testing/Ado/SimpleAdoTestUtils.cs | 10 +- src/Spring/Spring.Web/Caching/AspNetCache.cs | 3 +- .../DataBinding/DataSourceItemFormatter.cs | 3 +- .../HttpRequestBindingContainer.cs | 23 ++-- .../DataBinding/IBindingAwareFormatter.cs | 3 +- .../MultipleSelectionListControlBinding.cs | 9 +- .../Globalization/AspNetResourceCache.cs | 7 +- .../Xml/WebObjectDefinitionParserHelper.cs | 3 +- .../Spring.Web/Web/Support/MimeMediaType.cs | 5 +- .../Web/Support/SharedStateResourceCache.cs | 7 +- .../UI/Controls/AbstractValidationControl.cs | 9 +- .../Web/UI/Controls/CheckBoxList.cs | 11 +- .../Web/UI/Controls/LocalizedImage.cs | 10 +- .../Web/UI/Controls/RadioButtonGroup.cs | 3 +- src/Spring/Spring.Web/Web/UI/MasterPage.cs | 7 +- src/Spring/Spring.Web/Web/UI/Page.cs | 7 +- src/Spring/Spring.Web/Web/UI/UserControl.cs | 7 +- .../AbstractValidationErrorsRenderer.cs | 3 +- .../Validation/DivValidationErrorsRenderer.cs | 3 +- .../Validation/IValidationErrorsRenderer.cs | 3 +- .../IconValidationErrorsRenderer.cs | 6 +- .../SpanValidationErrorsRenderer.cs | 3 +- .../Aop/Config/AopNamespaceParserTests.cs | 2 +- .../AdvisorAdapterRegistrationTests.cs | 4 +- .../UnknownAdviceTypeExceptionTests.cs | 2 - ...AutoProxyCreatorCircularReferencesTests.cs | 4 +- .../AutoProxy/AdvisorAutoProxyCreatorTests.cs | 2 +- .../AttributeAutoProxyCreatorTests.cs | 3 +- .../Support/ApplicationObjectSupportTests.cs | 9 +- .../Support/ResourceSetMessageSourceTests.cs | 5 +- .../Expressions/ExpressionEvaluatorTests.cs | 61 ++++----- .../Expressions/FunctionNodeTests.cs | 7 +- .../Expressions/MethodNodeTests.cs | 3 +- .../Processors/OrderByProcessorTests.cs | 5 +- .../Config/DictionaryVariableSourceTests.cs | 3 +- .../DefaultListableObjectFactoryTests.cs | 17 +-- .../Factory/ObjectFactoryUtilsTests.cs | 9 +- .../Factory/Xml/XmlObjectFactoryTests.cs | 7 +- .../Util/StringUtilsTests.cs | 28 +++-- .../Actions/ExceptionActionTests.cs | 10 +- .../Actions/ExpressionActionTests.cs | 14 +-- .../Validation/HelperClasses.cs | 16 +-- .../Validation/ValidationErrorsTests.cs | 11 +- .../Validators/ConditionValidatorTests.cs | 4 +- .../LocalSessionFactoryObjectTests.cs | 5 +- .../Nms/Config/NmsNamespaceHandlerTests.cs | 10 +- ...annelFactoryObjectDefinitionParserTests.cs | 3 +- .../Caching/AspNetCacheTests.cs | 3 +- .../AbstractValidationControlTests.cs | 7 +- 224 files changed, 1319 insertions(+), 1245 deletions(-) diff --git a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceParser.cs b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceParser.cs index ac3955d6..d75f05e7 100644 --- a/src/Spring/Spring.Aop/Aop/Config/AopNamespaceParser.cs +++ b/src/Spring/Spring.Aop/Aop/Config/AopNamespaceParser.cs @@ -18,7 +18,6 @@ #endregion -using System; using Spring.Objects.Factory.Xml; namespace Spring.Aop.Config diff --git a/src/Spring/Spring.Aop/Aop/Framework/Adapter/AdvisorAdapterRegistrationManager.cs b/src/Spring/Spring.Aop/Aop/Framework/Adapter/AdvisorAdapterRegistrationManager.cs index 49c86fae..11469052 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/Adapter/AdvisorAdapterRegistrationManager.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/Adapter/AdvisorAdapterRegistrationManager.cs @@ -20,7 +20,6 @@ #region Imports -using System; using Spring.Objects.Factory.Config; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/Adapter/DefaultAdvisorAdapterRegistry.cs b/src/Spring/Spring.Aop/Aop/Framework/Adapter/DefaultAdvisorAdapterRegistry.cs index d5c2c7dc..396ff9c9 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/Adapter/DefaultAdvisorAdapterRegistry.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/Adapter/DefaultAdvisorAdapterRegistry.cs @@ -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 adapters = new List(); /// /// Creates a new instance of the diff --git a/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapter.cs b/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapter.cs index 71fe8484..8ac7f40a 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapter.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapter.cs @@ -20,7 +20,6 @@ #region Imports -using System; using AopAlliance.Aop; using AopAlliance.Intercept; diff --git a/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapterRegistry.cs b/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapterRegistry.cs index 1b571536..83549c50 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapterRegistry.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/Adapter/IAdvisorAdapterRegistry.cs @@ -20,7 +20,6 @@ #region Imports -using System; using AopAlliance.Intercept; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs index cc250005..56f90e4e 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs @@ -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. ///

/// - 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 CalculateInterceptors( IAdvised config, object proxy, MethodInfo method, Type targetType) { - IList interceptors = new ArrayList(config.Advisors.Length); + IList interceptors = new List(config.Advisors.Length); foreach (IAdvisor advisor in config.Advisors) { if (advisor is IPointcutAdvisor) diff --git a/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs b/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs index 1d058fae..5954a361 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AopContext.cs @@ -22,7 +22,6 @@ using System; using System.Collections; -using Spring.Threading; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AopUtils.cs b/src/Spring/Spring.Aop/Aop/Framework/AopUtils.cs index 3ceb7a54..f4cac8f3 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AopUtils.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AopUtils.cs @@ -21,8 +21,8 @@ #region Imports using System; -using System.Collections; using System.Reflection; + using Spring.Collections; using Spring.Util; diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs index a937aabc..0b923d81 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs @@ -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; diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs index 29c653b1..85e39cd3 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs @@ -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 advisors = new List(); 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 diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs index 57833631..823be501 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs @@ -21,9 +21,6 @@ #region Imports using System; -using System.Collections; -using Spring.Objects.Factory; -using Spring.Util; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AttributeAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AttributeAutoProxyCreator.cs index 5a2600fc..8764be79 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AttributeAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AttributeAutoProxyCreator.cs @@ -21,8 +21,7 @@ #region Imports using System; -using System.Collections; -using Spring.Aop.Support; + using Spring.Util; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs index 1b441e15..45aebb98 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs @@ -22,7 +22,7 @@ using System; using System.Collections; -using Spring.Context; + using Spring.Objects.Factory; #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs index 02c40933..e442f9d6 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs @@ -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 advisors = new List(); 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 diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs index 4a0d7141..956da743 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs @@ -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 advisors = new List(); if (advisorNames.Length == 0) { @@ -111,12 +113,12 @@ namespace Spring.Aop.Framework.AutoProxy /// /// 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(); ExceptionAction action = new ExceptionAction("new System.InvalidOperationException('invalid')"); try { @@ -73,7 +73,7 @@ namespace Spring.Validation.Actions public void WhenInvalidThrowCustomExceptionUsingSetter() { Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian"); - IDictionary vars = new Hashtable(); + Dictionary vars = new Dictionary(); ExceptionAction action = new ExceptionAction(); IExpression expression = Expression.Parse("new System.InvalidOperationException('invalid')"); action.ThrowsExpression = expression; @@ -93,7 +93,7 @@ namespace Spring.Validation.Actions public void WhenValid() { 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 { diff --git a/test/Spring/Spring.Core.Tests/Validation/Actions/ExpressionActionTests.cs b/test/Spring/Spring.Core.Tests/Validation/Actions/ExpressionActionTests.cs index 0aaba181..c645ed96 100644 --- a/test/Spring/Spring.Core.Tests/Validation/Actions/ExpressionActionTests.cs +++ b/test/Spring/Spring.Core.Tests/Validation/Actions/ExpressionActionTests.cs @@ -20,7 +20,7 @@ using System; using System.Collections; - +using System.Collections.Generic; using NUnit.Framework; using Spring.Expressions; @@ -38,7 +38,7 @@ namespace Spring.Validation.Actions public void WhenValid() { Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian"); - IDictionary vars = new Hashtable(); + Dictionary vars = new Dictionary(); ExpressionAction action = new ExpressionAction("#result = 'valid'", "#result = 'invalid'"); action.Execute(true, context, vars, null); @@ -57,14 +57,14 @@ namespace Spring.Validation.Actions vars.Clear(); action = new ExpressionAction(null, "#result = 'invalid'"); action.Execute(true, context, vars, null); - Assert.IsFalse(vars.Contains("result"), "Result should not exist when valid expression is null."); + Assert.IsFalse(vars.ContainsKey("result"), "Result should not exist when valid expression is null."); } [Test] public void WhenInvalid() { Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian"); - IDictionary vars = new Hashtable(); + Dictionary vars = new Dictionary(); ExpressionAction action = new ExpressionAction("#result = 'valid'", "#result = 'invalid'"); action.Execute(false, context, vars, null); @@ -83,19 +83,19 @@ namespace Spring.Validation.Actions vars.Clear(); action = new ExpressionAction("#result = 'valid'", null); action.Execute(false, context, vars, null); - Assert.IsFalse(vars.Contains("result"), "Result should not exist when invalid expression is null."); + Assert.IsFalse(vars.ContainsKey("result"), "Result should not exist when invalid expression is null."); } [Test] public void WhenActionIsNotExecutedBecauseWhenExpressionReturnsFalse() { Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian"); - IDictionary vars = new Hashtable(); + Dictionary vars = new Dictionary(); ExpressionAction action = new ExpressionAction("#result = 'valid'", "#result = 'invalid'"); action.When = Expression.Parse("false"); action.Execute(true, context, vars, null); - Assert.IsFalse(vars.Contains("result")); + Assert.IsFalse(vars.ContainsKey("result")); } } diff --git a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs index f0361405..31c761f4 100644 --- a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs +++ b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs @@ -20,7 +20,7 @@ using System; using System.Collections; - +using System.Collections.Generic; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Validation.Actions; @@ -36,7 +36,7 @@ namespace Spring.Validation get { return _wasCalled; } } - public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors) + public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors) { _wasCalled = true; return base.Validate (validationContext, contextParams, errors); @@ -85,7 +85,7 @@ namespace Spring.Validation public sealed class MockObjectDefinitionRegistry : IObjectDefinitionRegistry { - private IDictionary objects = new Hashtable(); + private IDictionary objects = new Dictionary(); public int ObjectDefinitionCount { @@ -94,22 +94,24 @@ namespace Spring.Validation public string[] GetObjectDefinitionNames() { - return (string[]) new ArrayList(this.objects.Keys).ToArray(typeof(string)); + return new List(this.objects.Keys).ToArray(); } public IObjectDefinition[] GetObjectDefinitions() { - return (IObjectDefinition[]) new ArrayList(this.objects.Values).ToArray(typeof(IObjectDefinition)); + return new List(this.objects.Values).ToArray(); } public bool ContainsObjectDefinition(string name) { - return objects.Contains(name); + return objects.ContainsKey(name); } public IObjectDefinition GetObjectDefinition(string name) { - return (IObjectDefinition) objects[name]; + IObjectDefinition definition; + objects.TryGetValue(name, out definition); + return definition; } public void RegisterObjectDefinition(string name, IObjectDefinition definition) diff --git a/test/Spring/Spring.Core.Tests/Validation/ValidationErrorsTests.cs b/test/Spring/Spring.Core.Tests/Validation/ValidationErrorsTests.cs index fd10cb36..6115599d 100644 --- a/test/Spring/Spring.Core.Tests/Validation/ValidationErrorsTests.cs +++ b/test/Spring/Spring.Core.Tests/Validation/ValidationErrorsTests.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Xml.Serialization; using NUnit.Framework; @@ -49,7 +50,7 @@ namespace Spring.Validation { ValidationErrors errors = new ValidationErrors(); errors.AddError(string.Empty, ErrorMessageOne); - IList resolvedErrors = errors.GetResolvedErrors(string.Empty, null); + IList resolvedErrors = errors.GetResolvedErrors(string.Empty, null); Assert.AreEqual(ErrorMessageOne.Id, (string)resolvedErrors[0]); } [Test] @@ -101,11 +102,11 @@ namespace Spring.Validation { IValidationErrors errors = new ValidationErrors(); - IList typedErrors = errors.GetErrors("xyz"); + IList typedErrors = errors.GetErrors("xyz"); Assert.IsNotNull(typedErrors); Assert.AreEqual(0, typedErrors.Count); - IList resolvedErrors = errors.GetResolvedErrors("xyz", new NullMessageSource()); + IList resolvedErrors = errors.GetResolvedErrors("xyz", new NullMessageSource()); Assert.IsNotNull(resolvedErrors); Assert.AreEqual(0, resolvedErrors.Count); } @@ -138,13 +139,13 @@ namespace Spring.Validation errors.MergeErrors(otherErrors); Assert.IsFalse(errors.IsEmpty); - IList mergedErrors = errors.GetErrors(GoodErrorKey); + IList mergedErrors = errors.GetErrors(GoodErrorKey); Assert.IsNotNull(mergedErrors); Assert.AreEqual(2, mergedErrors.Count); Assert.AreEqual(ErrorMessageOne, mergedErrors[0]); Assert.AreEqual(ErrorMessageTwo, mergedErrors[1]); - IList otherErrorsForKey = errors.GetErrors(anotherKey); + IList otherErrorsForKey = errors.GetErrors(anotherKey); Assert.IsNotNull(otherErrorsForKey); Assert.AreEqual(1, otherErrorsForKey.Count); Assert.AreEqual(ErrorMessageTwo, otherErrorsForKey[0]); diff --git a/test/Spring/Spring.Core.Tests/Validation/Validators/ConditionValidatorTests.cs b/test/Spring/Spring.Core.Tests/Validation/Validators/ConditionValidatorTests.cs index 7a023792..36806309 100644 --- a/test/Spring/Spring.Core.Tests/Validation/Validators/ConditionValidatorTests.cs +++ b/test/Spring/Spring.Core.Tests/Validation/Validators/ConditionValidatorTests.cs @@ -21,7 +21,7 @@ #region Imports using System.Collections; - +using System.Collections.Generic; using NUnit.Framework; using Spring.Context.Support; @@ -75,7 +75,7 @@ namespace Spring.Validation.Validators IValidationErrors errors = new ValidationErrors(); Assert.IsFalse(validator.Validate(tesla, errors)); Assert.IsFalse(errors.IsEmpty); - IList namedErrors = errors.GetResolvedErrors("InventorValidator", new NullMessageSource()); + IList namedErrors = errors.GetResolvedErrors("InventorValidator", new NullMessageSource()); Assert.AreEqual(1, namedErrors.Count); string error = (string) namedErrors[0]; Assert.AreEqual("Wrong name", error); diff --git a/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/LocalSessionFactoryObjectTests.cs b/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/LocalSessionFactoryObjectTests.cs index 9c6ead15..547a0fb7 100644 --- a/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/LocalSessionFactoryObjectTests.cs +++ b/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/LocalSessionFactoryObjectTests.cs @@ -19,6 +19,7 @@ #endregion using System.Collections; +using System.Collections.Generic; using System.IO; using NHibernate; @@ -52,7 +53,7 @@ namespace Spring.Data.NHibernate sfo.DbProvider = dbProvider; sfo.ApplicationContext = new StaticApplicationContext(); - IDictionary properties = new Hashtable(); + Dictionary properties = new Dictionary(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionDriver, typeof(SqlClientDriver).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName); @@ -88,7 +89,7 @@ namespace Spring.Data.NHibernate public void LocalSessionFactoryObjectWithInvalidProperties() { LocalSessionFactoryObject sfo = new LocalSessionFactoryObject(); - IDictionary properties = new Hashtable(); + Dictionary properties = new Dictionary(); properties.Add(Environment.Dialect, typeof(MsSql2000Dialect).AssemblyQualifiedName); properties.Add(Environment.ConnectionProvider, "myClass"); sfo.HibernateProperties = properties; diff --git a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs index 0a3b9c4c..dd737519 100644 --- a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs +++ b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs @@ -20,7 +20,7 @@ #region Imports -using System.Collections; +using System.Collections.Generic; using Apache.NMS; using NUnit.Framework; using Rhino.Mocks; @@ -73,23 +73,23 @@ namespace Spring.Messaging.Nms.Config [Test] public void ObjectsCreated() { - IDictionary containers = ctx.GetObjectsOfType(typeof(SimpleMessageListenerContainer)); + IDictionary containers = ctx.GetObjectsOfType(); Assert.AreEqual(3, containers.Count); } [Test] public void ContainerConfiguration() { - IDictionary containers = ctx.GetObjectsOfType(typeof (SimpleMessageListenerContainer)); + IDictionary containers = ctx.GetObjectsOfType(); IConnectionFactory defaultConnectionFactory = (IConnectionFactory) ctx.GetObject(DEFAULT_CONNECTION_FACTORY); IConnectionFactory explicitConnectionFactory = (IConnectionFactory) ctx.GetObject(EXPLICIT_CONNECTION_FACTORY); int defaultConnectionFactoryCount = 0; int explicitConnectionFactoryCount = 0; - foreach (DictionaryEntry dictionaryEntry in containers) + foreach (KeyValuePair dictionaryEntry in containers) { - SimpleMessageListenerContainer container = (SimpleMessageListenerContainer) dictionaryEntry.Value; + SimpleMessageListenerContainer container = dictionaryEntry.Value; if (container.ConnectionFactory.Equals(defaultConnectionFactory)) { defaultConnectionFactoryCount++; diff --git a/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs b/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs index 660fe48a..ac1a5224 100644 --- a/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs +++ b/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs @@ -21,6 +21,7 @@ #region Imports using System.Collections; +using System.Collections.Generic; using System.ServiceModel; using Spring.Context; @@ -103,7 +104,7 @@ namespace Spring.ServiceModel.Config IApplicationContext ctx = new XmlApplicationContext( ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.WithoutId.xml", this.GetType())); - IDictionary channels = ctx.GetObjectsOfType(typeof(IContract)); + IDictionary channels = ctx.GetObjectsOfType(); Assert.AreEqual(1, channels.Count); } diff --git a/test/Spring/Spring.Web.Tests/Caching/AspNetCacheTests.cs b/test/Spring/Spring.Web.Tests/Caching/AspNetCacheTests.cs index 4b530202..3eb382cb 100644 --- a/test/Spring/Spring.Web.Tests/Caching/AspNetCacheTests.cs +++ b/test/Spring/Spring.Web.Tests/Caching/AspNetCacheTests.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Threading; using System.Web; using System.Web.Caching; @@ -122,7 +123,7 @@ namespace Spring.Caching mocks.ReplayAll(); // verify ICollection keys = mockedCache.Keys; - Assert.AreEqual( new string[] { "keyA", "keyB" }, new ArrayList(keys).ToArray(typeof(string)) ); + CollectionAssert.AreEqual(new string[] { "keyA", "keyB" }, keys); mocks.VerifyAll(); } diff --git a/test/Spring/Spring.Web.Tests/Web/UI/Controls/AbstractValidationControlTests.cs b/test/Spring/Spring.Web.Tests/Web/UI/Controls/AbstractValidationControlTests.cs index 4ec4aa0c..301d6eaf 100644 --- a/test/Spring/Spring.Web.Tests/Web/UI/Controls/AbstractValidationControlTests.cs +++ b/test/Spring/Spring.Web.Tests/Web/UI/Controls/AbstractValidationControlTests.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Globalization; using System.Web.UI; using NUnit.Framework; @@ -280,7 +281,7 @@ namespace Spring.Web.UI.Controls { public class CapturingRenderer : IValidationErrorsRenderer { - public IList LastErrorsRendered; + public IList LastErrorsRendered; private readonly IValidationErrorsRenderer _inner; public CapturingRenderer(IValidationErrorsRenderer inner) @@ -288,7 +289,7 @@ namespace Spring.Web.UI.Controls _inner = inner; } - public void RenderErrors(Page page, HtmlTextWriter writer, IList errors) + public void RenderErrors(Page page, HtmlTextWriter writer, IList errors) { LastErrorsRendered = errors; if (_inner != null) @@ -319,7 +320,7 @@ namespace Spring.Web.UI.Controls return _ver; } - public IList LastErrorsRendered + public IList LastErrorsRendered { get { return ((CapturingRenderer)_ver).LastErrorsRendered; } } From f498ba2264d1fcafdfc7b432ea017d4258d56043 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 24 Mar 2012 12:33:08 +0200 Subject: [PATCH 2/4] Fix compilation issues under VS2008 --- .../Context/Support/AbstractApplicationContext.cs | 8 ++++---- src/Spring/Spring.Core/Spring.Core.2008.csproj | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs index 5d01f926..a7d80da3 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs @@ -516,7 +516,7 @@ namespace Spring.Context.Support IDictionary objectMap = objectFactory.GetObjectsOfType(true, false); List registryPostProcessorObjects = new List(objectMap.Values); - registryPostProcessorObjects.Sort(new OrderComparator()); + registryPostProcessorObjects.Sort(new OrderComparator()); foreach (object processor in registryPostProcessorObjects) { @@ -589,7 +589,7 @@ namespace Spring.Context.Support { orderedFactoryProcessors.Add(ObjectFactory.GetObject(orderedFactoryProcessorsName)); } - orderedFactoryProcessors.Sort(new OrderComparator()); + orderedFactoryProcessors.Sort(new OrderComparator()); InvokeObjectFactoryPostProcessors(orderedFactoryProcessors, ObjectFactory); // and then the unordered ones... @@ -616,7 +616,7 @@ namespace Spring.Context.Support protected virtual void InvokePriorityOrderedObjectFactoryPostProcessors(List factoryProcessorNames, List priorityOrderedFactoryProcessors) { - priorityOrderedFactoryProcessors.Sort(new OrderComparator()); + priorityOrderedFactoryProcessors.Sort(new OrderComparator()); InvokeObjectFactoryPostProcessors(priorityOrderedFactoryProcessors, ObjectFactory); // Now will find any additional IObjectFactoryPostProcessors that implement IPriorityOrdered that may have been @@ -634,7 +634,7 @@ namespace Spring.Context.Support } } // Second, invoke newly discovered IObjectFactoryPostProcessors that implement IPriorityOrdered. - priorityOrderedFactoryProcessors.Sort(new OrderComparator()); + priorityOrderedFactoryProcessors.Sort(new OrderComparator()); InvokeObjectFactoryPostProcessors(priorityOrderedFactoryProcessors, ObjectFactory); } diff --git a/src/Spring/Spring.Core/Spring.Core.2008.csproj b/src/Spring/Spring.Core/Spring.Core.2008.csproj index dae1a802..41e0f086 100644 --- a/src/Spring/Spring.Core/Spring.Core.2008.csproj +++ b/src/Spring/Spring.Core/Spring.Core.2008.csproj @@ -93,6 +93,9 @@ + + 3.5 + From 68b67e3f45a30039c3466f548fe9a698ff32f4d4 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 24 Mar 2012 13:29:11 +0200 Subject: [PATCH 3/4] Fix remaining issues that were spotted by build and test system --- .../src/Spring.AopQuickStart.Step7/Program.cs | 4 +-- .../TxQuickStart/AccountManagerTests.cs | 5 ++-- .../Support/AbstractApplicationContext.cs | 2 +- .../Support/GenericApplicationContext.cs | 28 +++++++++---------- .../Support/DefaultListableObjectFactory.cs | 2 +- .../Support/StaticListableObjectFactory.cs | 24 +++++++++++----- .../Spring.Web.Mvc/SpringControllerFactory.cs | 6 ++-- .../SpringMvcDependencyResolver.cs | 4 +-- 8 files changed, 41 insertions(+), 34 deletions(-) diff --git a/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs b/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs index d3743d27..ac68e6c0 100644 --- a/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs +++ b/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs @@ -21,7 +21,7 @@ #region Imports using System; -using System.Collections; +using System.Collections.Generic; using Spring.Context; using Spring.Context.Support; @@ -47,7 +47,7 @@ namespace Spring.AopQuickStart { // Create AOP proxy using Spring.NET IoC container. IApplicationContext ctx = ContextRegistry.GetContext(); - IDictionary commands = ctx.GetObjectsOfType(typeof(ICommand)); + IDictionary commands = ctx.GetObjectsOfType(); foreach (ICommand command in commands.Values) { diff --git a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs index d9bfead1..7bc7be33 100644 --- a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs +++ b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs @@ -21,7 +21,7 @@ #region Imports using System; -using System.Collections; +using System.Collections.Generic; using System.Data; using NUnit.Framework; using Spring.Aop.Config; @@ -30,7 +30,6 @@ using Spring.Context.Support; using Spring.Data.Common; using Spring.Data.Config; using Spring.Data.Core; -using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; using Spring.Transaction.Config; using Spring.TxQuickStart.Services; @@ -55,7 +54,7 @@ namespace Spring.TxQuickStart NamespaceParserRegistry.RegisterParser(typeof(TxNamespaceParser)); NamespaceParserRegistry.RegisterParser(typeof(AopNamespaceParser)); IApplicationContext context = CreateContextFromXml(); - IDictionary dict = context.GetObjectsOfType(typeof (IAccountManager)); + IDictionary dict = context.GetObjectsOfType(); accountManager = context["accountManager"] as IAccountManager; CleanDb(context); } diff --git a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs index a7d80da3..42e31143 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs @@ -1444,7 +1444,7 @@ namespace Spring.Context.Support /// public IDictionary GetObjectsOfType() { - return (IDictionary) GetObjectsOfType(typeof(T)); + return ObjectFactory.GetObjectsOfType(true, true); } /// diff --git a/src/Spring/Spring.Core/Context/Support/GenericApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/GenericApplicationContext.cs index 7b29ec14..cef3d73c 100644 --- a/src/Spring/Spring.Core/Context/Support/GenericApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/GenericApplicationContext.cs @@ -1,19 +1,19 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs index 20eca0d3..b30915d7 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs @@ -27,7 +27,7 @@ using System.Collections.Specialized; using System.Globalization; using Common.Logging; -using Spring.Collections.Generic; + using Spring.Core; using Spring.Core.TypeConversion; using Spring.Objects.Factory.Config; diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs index 6342512f..03244397 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs @@ -19,6 +19,7 @@ #region Imports using System; +using System.Collections; using System.Collections.Generic; using Spring.Objects.Factory.Config; @@ -817,7 +818,9 @@ namespace Spring.Objects.Factory.Support /// public IDictionary GetObjectsOfType() { - return (IDictionary) GetObjectsOfType(typeof(T)); + Dictionary collector = new Dictionary(); + DoGetObjectsOfType(typeof(T), true, true, collector); + return collector; } /// @@ -847,9 +850,15 @@ namespace Spring.Objects.Factory.Support /// If the objects could not be created. /// public IDictionary GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects) + { + Dictionary collector = new Dictionary(); + DoGetObjectsOfType(type, includeFactoryObjects, includePrototypes, collector); + return collector; + } + + private void DoGetObjectsOfType(Type type, bool includeFactoryObjects, bool includePrototypes, IDictionary collector) { bool isFactoryType = (type != null && typeof(IFactoryObject).IsAssignableFrom(type)); - IDictionary matches = new Dictionary(); foreach (string name in objects.Keys) { object instance = objects[name]; @@ -864,7 +873,7 @@ namespace Spring.Objects.Factory.Support object createdObject = GetObject(name); if (type.IsInstanceOfType(createdObject)) { - matches[name] = createdObject; + collector[name] = createdObject; } } } @@ -872,15 +881,14 @@ namespace Spring.Objects.Factory.Support { if (isFactoryType) { - matches[ObjectFactoryUtils.BuildFactoryObjectName(name)] = instance; + collector[ObjectFactoryUtils.BuildFactoryObjectName(name)] = instance; } else { - matches[name] = instance; + collector[name] = instance; } } } - return matches; } /// @@ -911,7 +919,9 @@ namespace Spring.Objects.Factory.Support /// public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects) { - return (IDictionary) GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects); + Dictionary collector = new Dictionary(); + DoGetObjectsOfType(typeof(T), includeFactoryObjects, includePrototypes, collector); + return collector; } /// diff --git a/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs b/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs index f36c2071..e1acf477 100644 --- a/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs +++ b/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs @@ -21,12 +21,10 @@ using System; using System.Web.Mvc; using System.Web.Routing; -using Spring.Objects.Factory; -using Spring.Core; + using Spring.Context; using Spring.Context.Support; using System.Linq; -using System.Collections; namespace Spring.Web.Mvc { @@ -116,7 +114,7 @@ namespace Spring.Web.Mvc var controllers = ApplicationContext.GetObjectsOfType(controllerType); if (controllers.Count > 0) { - controller = (IController)controllers.Cast().First().Value; + controller = (IController)controllers.First().Value; } } diff --git a/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs b/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs index 6210c6d1..42f660b6 100644 --- a/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs +++ b/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs @@ -74,7 +74,7 @@ namespace Spring.Web.Mvc var services = ApplicationContext.GetObjectsOfType(serviceType); if (services.Count > 0) { - service = services.Cast().First().Value; + service = services.First().Value; } } @@ -89,7 +89,7 @@ namespace Spring.Web.Mvc public IEnumerable GetServices(Type serviceType) { var services = ApplicationContext.GetObjectsOfType(serviceType); - return services.Values.Cast(); + return services.Values; } } } From 7778994f050698efbedd5d1d78300902ba3b42ce Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Mon, 26 Mar 2012 08:45:50 +0300 Subject: [PATCH 4/4] Changing from arrays to IList, generify AOP API, change GetObjectsOfType to GetObjects and GetObjectNamesForType to GetObjectNames --- .../src/Spring.AopQuickStart.Step7/Program.cs | 2 +- .../TxQuickStart/AccountManagerTests.cs | 2 +- .../Aop/Framework/AbstractMethodInvocation.cs | 2 +- .../Aop/Framework/AdvisedSupport.cs | 25 +- .../Aop/Framework/AdvisorChainFactoryUtils.cs | 2 +- .../AbstractAdvisorAutoProxyCreator.cs | 33 ++- .../AutoProxy/AbstractAutoProxyCreator.cs | 47 ++-- .../AbstractFilteringAutoProxyCreator.cs | 3 +- .../DefaultAdvisorAutoProxyCreator.cs | 6 +- .../AutoProxy/IAdvisorRetrievalHelper.cs | 3 +- .../InheritanceBasedAopConfigurer.cs | 10 +- .../ObjectFactoryAdvisorRetrievalHelper.cs | 49 ++-- .../DynamicProxy/AbstractAopProxyFactory.cs | 2 +- .../Framework/DynamicProxy/AdvisedProxy.cs | 12 +- .../DynamicProxy/CachedAopProxyFactory.cs | 19 +- .../DynamicProxy/DefaultAopProxyFactory.cs | 2 +- .../Spring.Aop/Aop/Framework/IAdvised.cs | 7 +- .../Aop/Framework/ProxyFactoryObject.cs | 38 +-- src/Spring/Spring.Aop/Spring.Aop.2008.csproj | 3 + .../Context/IMessageSourceResolvable.cs | 13 +- .../Support/AbstractApplicationContext.cs | 48 ++-- .../Context/Support/AbstractMessageSource.cs | 9 +- .../Context/Support/ContextHandler.cs | 42 +-- .../Support/DefaultMessageSourceResolvable.cs | 29 +- .../Support/DelegatingMessageSource.cs | 5 +- .../TypeResolution/TypeResolutionUtils.cs | 5 +- .../Expressions/ConstructorNode.cs | 8 +- .../Spring.Core/Expressions/MethodNode.cs | 8 +- .../RequiredAttributeObjectPostProcessor.cs | 9 +- .../IInstantiationAwareObjectPostProcessor.cs | 42 +-- .../Factory/Config/IObjectDefinition.cs | 3 +- .../Config/ISingletonObjectRegistry.cs | 4 +- ...ntiationAwareObjectPostProcessorAdapter.cs | 4 +- .../Factory/Config/ObjectDefinitionHolder.cs | 11 +- .../Factory/Config/ObjectDefinitionVisitor.cs | 2 +- .../Config/PropertyPlaceholderConfigurer.cs | 10 +- .../Config/VariablePlaceholderConfigurer.cs | 5 +- .../Objects/Factory/IListableObjectFactory.cs | 262 +++++++++--------- .../Objects/Factory/IObjectFactory.cs | 31 ++- .../Objects/Factory/ObjectFactoryUtils.cs | 16 +- .../AbstractAutowireCapableObjectFactory.cs | 32 +-- .../Support/AbstractObjectDefinition.cs | 18 +- .../Factory/Support/AbstractObjectFactory.cs | 17 +- .../Objects/Factory/Support/AutowireUtils.cs | 6 +- .../Factory/Support/ConstructorResolver.cs | 14 +- .../Support/DefaultListableObjectFactory.cs | 47 ++-- .../Support/IConfigurableObjectDefinition.cs | 4 +- .../Support/IObjectDefinitionRegistry.cs | 42 +-- .../Support/ObjectDefinitionBuilder.cs | 2 +- .../Support/ObjectDefinitionReaderUtils.cs | 8 +- .../Support/StaticListableObjectFactory.cs | 31 +-- .../Xml/ObjectDefinitionParserHelper.cs | 8 +- .../Factory/Xml/ObjectsNamespaceParser.cs | 4 +- .../Spring.Core/Objects/IPropertyValues.cs | 3 +- .../Objects/MutablePropertyValues.cs | 26 +- .../PropertyAccessExceptionsException.cs | 5 +- .../Proxy/AbstractProxyTypeBuilder.cs | 38 +-- .../Proxy/CompositionProxyTypeBuilder.cs | 2 +- .../Spring.Core/Proxy/IProxyTypeBuilder.cs | 3 +- src/Spring/Spring.Core/Util/EventUtils.cs | 8 +- .../Util/IEventExceptionsCollector.cs | 5 +- .../Spring.Core/Util/ReflectionUtils.cs | 11 +- src/Spring/Spring.Core/Util/StringUtils.cs | 12 +- .../NHibernate/Bytecode/ObjectsFactory.cs | 9 +- .../Bytecode/ReflectionOptimizer.cs | 5 +- .../NHibernate/LocalSessionFactoryObject.cs | 2 +- .../Data/NHibernate/SessionFactoryUtils.cs | 4 +- .../Data/Common/DbProviderFactory.cs | 6 +- .../Spring.Data/Data/Core/AdoTemplate.cs | 3 +- .../TransactionProxyFactoryObject.cs | 3 +- .../Connections/ChainedExceptionListener.cs | 4 +- .../Core/DefaultMessageQueueFactory.cs | 2 +- .../Core/MessageQueueMetadataCache.cs | 2 +- .../Scheduling/Quartz/QuartzJobObject.cs | 13 +- .../Quartz/SchedulerAccessorObject.cs | 5 +- .../Quartz/SpringObjectJobFactory.cs | 18 +- .../ServiceModel/ServiceExporter.cs | 9 +- .../Web/Services/WebServiceProxyFactory.cs | 2 +- .../Config/TemplateNamespaceParser.cs | 12 +- .../Velocity/VelocityEngineFactory.cs | 9 +- .../Microsoft/AbstractSpringContextTests.cs | 4 +- ...ctDependencyInjectionSpringContextTests.cs | 11 +- .../NUnit/AbstractSpringContextTests.cs | 4 +- .../Context/Support/WebContextHandler.cs | 19 +- .../Xml/WebObjectDefinitionParserHelper.cs | 2 +- .../Spring.Web/Web/Support/ContextMonitor.cs | 3 +- .../Aop/Config/AopNamespaceParserTests.cs | 6 +- .../AbstractAdvisorAutoProxyCreatorTests.cs | 35 +-- .../AbstractAutoProxyCreatorTests.cs | 33 +-- ...AutoProxyCreatorCircularReferencesTests.cs | 5 +- .../InfrastructureAdvisorAutoProxyCreator.cs | 35 +-- .../DynamicProxy/AbstractAopProxyTests.cs | 12 +- .../Aop/Framework/ProxyFactoryObjectTests.cs | 34 +-- .../Aop/Framework/ProxyFactoryTests.cs | 8 +- .../CaptureOutputLoggerFactoryAdapter.cs | 8 +- .../Support/ApplicationObjectSupportTests.cs | 17 +- .../TypeResolutionUtilsTests.cs | 5 +- .../AbstractListableObjectFactoryTests.cs | 19 +- .../Factory/AbstractObjectFactoryTests.cs | 2 +- .../DefaultListableObjectFactoryTests.cs | 18 +- .../Factory/ObjectFactoryUtilsTests.cs | 18 +- .../Support/ChildObjectDefinitionTests.cs | 2 +- .../DefaultObjectDefinitionFactoryTests.cs | 6 +- .../Support/RootObjectDefinitionTests.cs | 8 +- ...supportedObjectDefinitionImplementation.cs | 4 +- .../Xml/XmlListableObjectFactoryTests.cs | 8 +- .../Factory/Xml/XmlObjectCollectionTests.cs | 9 +- .../Xml/XmlObjectDefinitionReaderTests.cs | 2 +- .../Factory/Xml/XmlObjectFactoryTests.cs | 4 +- .../Objects/MutablePropertyValuesTests.cs | 49 ++-- .../Util/DefensiveEventRaiserTests.cs | 2 +- .../Util/ReflectionUtilsTests.cs | 5 +- .../Util/StringUtilsTests.cs | 7 +- .../Validation/HelperClasses.cs | 10 +- .../ValidationNamespaceParserTests.cs | 5 +- .../Data/Common/DbProviderFactoryTests.cs | 5 +- .../Nms/Config/NmsNamespaceHandlerTests.cs | 4 +- ...tandardReflectionMessageListenerAdapter.cs | 4 +- ...annelFactoryObjectDefinitionParserTests.cs | 2 +- .../WebObjectDefinitionFactoryTests.cs | 6 +- 120 files changed, 883 insertions(+), 844 deletions(-) diff --git a/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs b/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs index ac68e6c0..be74d10c 100644 --- a/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs +++ b/examples/Spring/Spring.AopQuickStart/src/Spring.AopQuickStart.Step7/Program.cs @@ -47,7 +47,7 @@ namespace Spring.AopQuickStart { // Create AOP proxy using Spring.NET IoC container. IApplicationContext ctx = ContextRegistry.GetContext(); - IDictionary commands = ctx.GetObjectsOfType(); + IDictionary commands = ctx.GetObjects(); foreach (ICommand command in commands.Values) { diff --git a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs index 7bc7be33..ff480e28 100644 --- a/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs +++ b/examples/Spring/Spring.TxQuickStart/test/Spring/Spring.TxQuickStart.Tests/TxQuickStart/AccountManagerTests.cs @@ -54,7 +54,7 @@ namespace Spring.TxQuickStart NamespaceParserRegistry.RegisterParser(typeof(TxNamespaceParser)); NamespaceParserRegistry.RegisterParser(typeof(AopNamespaceParser)); IApplicationContext context = CreateContextFromXml(); - IDictionary dict = context.GetObjectsOfType(); + IDictionary dict = context.GetObjects(); accountManager = context["accountManager"] as IAccountManager; CleanDb(context); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AbstractMethodInvocation.cs b/src/Spring/Spring.Aop/Aop/Framework/AbstractMethodInvocation.cs index 213563c3..17bc760b 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AbstractMethodInvocation.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AbstractMethodInvocation.cs @@ -357,7 +357,7 @@ namespace Spring.Aop.Framework { StringBuilder buffer = new StringBuilder("Invocation: method '"); buffer.Append(Method.Name).Append("', ").Append("arguments "); - buffer.Append(this.arguments != null ? StringUtils.ArrayToCommaDelimitedString(this.arguments) : "[none]"); + buffer.Append(this.arguments != null ? StringUtils.CollectionToCommaDelimitedString(this.arguments) : "[none]"); buffer.Append("; "); if (this.target == null) { diff --git a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs index 56f90e4e..d305f805 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AdvisedSupport.cs @@ -294,7 +294,7 @@ namespace Spring.Aop.Framework /// to be (or that are being) proxied by this proxy. /// /// - public virtual Type[] Interfaces + public virtual IList Interfaces { get { @@ -318,12 +318,12 @@ namespace Spring.Aop.Framework /// /// Set interfaces to be proxied, bypassing locking and /// - protected void SetInterfacesInternal(Type[] value) + protected void SetInterfacesInternal(IList value) { this.interfaceMap.Clear(); if (value != null) { - for (int i = 0; i < value.Length; i++) + for (int i = 0; i < value.Count; i++) { AddInterfaceInternal(value[i]); } @@ -392,14 +392,9 @@ namespace Spring.Aop.Framework /// instances that have been applied to this proxy. /// /// - public virtual IAdvisor[] Advisors + public virtual IList Advisors { - get - { - { - return _advisorsArray; - } - } + get { return _advisorsArray; } } /// @@ -419,13 +414,13 @@ namespace Spring.Aop.Framework /// instances that have been applied to this proxy. /// /// - public virtual IIntroductionAdvisor[] Introductions + public virtual IList Introductions { get { lock (this.SyncRoot) { - return this._introductions.ToArray(); + return this._introductions; } } } @@ -1491,7 +1486,7 @@ namespace Spring.Aop.Framework /// protected internal virtual void CopyConfigurationFrom(AdvisedSupport other) { - CopyConfigurationFrom(other, other.TargetSource, new List(other.Advisors), new List(other.Introductions)); + CopyConfigurationFrom(other, other.TargetSource, new List(other.Advisors), new List(other.Introductions)); } /// @@ -1514,14 +1509,14 @@ 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; this.m_targetSource = targetSource; // this.cachedProxyType = other.cachedProxyType; // this.cachedProxyConstructor = other.cachedProxyConstructor; - this.Interfaces = (Type[]) CollectionUtils.ToArray(other.Interfaces, typeof(Type)); + this.Interfaces = new List(other.Interfaces); foreach (Type intf in other.interfaceMap.Keys) { this.interfaceMap[intf] = other.interfaceMap[intf]; diff --git a/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs b/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs index 935898d8..d4ebd34e 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AdvisorChainFactoryUtils.cs @@ -67,7 +67,7 @@ namespace Spring.Aop.Framework public static IList CalculateInterceptors( IAdvised config, object proxy, MethodInfo method, Type targetType) { - IList interceptors = new List(config.Advisors.Length); + IList interceptors = new List(config.Advisors.Count); foreach (IAdvisor advisor in config.Advisors) { if (advisor is IPointcutAdvisor) diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs index 0b923d81..6144760e 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs @@ -22,13 +22,14 @@ using System; using System.Collections; - +using System.Collections.Generic; using Common.Logging; using Spring.Core; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Util; +using System.Linq; #endregion @@ -125,20 +126,20 @@ namespace Spring.Aop.Framework.AutoProxy /// the type of the target object /// the name of the target object /// targetSource returned by TargetSource property: - /// may be ignored. Will be null unless a custom target source is in use. + /// may be ignored. Will be null unless a custom target source is in use. /// /// an array of additional interceptors for the particular object; /// or an empty array if no additional interceptors but just the common ones; /// or null if no proxy at all, not even with the common interceptors. /// - protected override object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) + protected override IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) { - IList advisors = FindEligibleAdvisors(targetType, targetName); + IList advisors = FindEligibleAdvisors(targetType, targetName); if (advisors.Count == 0) { return DO_NOT_PROXY; } - return (object[]) CollectionUtils.ToArray(advisors, typeof (object)); + return advisors.Cast().ToArray(); } /// @@ -150,10 +151,10 @@ namespace Spring.Aop.Framework.AutoProxy /// the empty list, not null, if there are no pointcuts or interceptors. /// The by-order sorted list of advisors otherwise /// - protected IList FindEligibleAdvisors(Type targetType, string targetName) + protected IList FindEligibleAdvisors(Type targetType, string targetName) { - IList candidateAdvisors = FindCandidateAdvisors(targetType, targetName); - IList eligibleAdvisors = FindAdvisorsThatCanApply(candidateAdvisors, targetType, targetName); + IList candidateAdvisors = FindCandidateAdvisors(targetType, targetName); + IList eligibleAdvisors = FindAdvisorsThatCanApply(candidateAdvisors, targetType, targetName); ExtendAdvisors(eligibleAdvisors, targetType, targetName); eligibleAdvisors = SortAdvisors(eligibleAdvisors); @@ -167,7 +168,7 @@ namespace Spring.Aop.Framework.AutoProxy /// the type of the object to be advised /// the name of the object to be advised /// the list of candidate advisors - protected virtual IList FindCandidateAdvisors(Type targetType, string targetName) + protected virtual IList FindCandidateAdvisors(Type targetType, string targetName) { return _advisorRetrievalHelper.FindAdvisorObjects(targetType, targetName); } @@ -180,14 +181,14 @@ namespace Spring.Aop.Framework.AutoProxy /// the target object's type /// the target object's name /// the list of applicable advisors - protected virtual IList FindAdvisorsThatCanApply(IList candidateAdvisors, Type targetType, string targetName) + protected virtual IList FindAdvisorsThatCanApply(IList candidateAdvisors, Type targetType, string targetName) { if (candidateAdvisors.Count==0) { return candidateAdvisors; } - ArrayList eligibleAdvisors = new ArrayList(); + List eligibleAdvisors = new List(); foreach(IAdvisor candidate in candidateAdvisors) { if (candidate is IIntroductionAdvisor && AopUtils.CanApply(candidate, targetType, null)) @@ -230,14 +231,16 @@ namespace Spring.Aop.Framework.AutoProxy /// /// The advisors. /// - protected virtual IList SortAdvisors(IList advisors) + protected virtual IList SortAdvisors(IList advisors) { if (advisors.Count==0) { return advisors; - } + } - if (advisors is ArrayList) + if (advisors is List) + ((List)advisors).Sort(new OrderComparator()); + else if (advisors is ArrayList) ((ArrayList) advisors).Sort(new OrderComparator()); else if (advisors is Array) Array.Sort((Array) advisors, new OrderComparator()); @@ -257,7 +260,7 @@ namespace Spring.Aop.Framework.AutoProxy /// Advisors that have already been identified as applying to a given object /// the type of the object to be advised /// the name of the object to be advised - protected virtual void ExtendAdvisors(IList advisors, Type objectType, string objectName) + protected virtual void ExtendAdvisors(IList advisors, Type objectType, string objectName) {} /// diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs index 85e39cd3..4e45a493 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs @@ -21,6 +21,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Runtime.Remoting; @@ -82,13 +83,13 @@ namespace Spring.Aop.Framework.AutoProxy /// /// Convenience constant for subclasses: Return value for "do not proxy". /// - protected static readonly object[] DO_NOT_PROXY = null; + protected static readonly IList DO_NOT_PROXY = null; /// /// Convenience constant for subclasses: Return value for /// "proxy without additional interceptors, just the common ones". /// - protected static readonly object[] PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS = new object[0]; + protected static readonly IList PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS = new List(0); #endregion @@ -286,8 +287,7 @@ namespace Spring.Aop.Framework.AutoProxy } //ITargetSource targetSource = GetCustomTargetSource(obj.GetType(), objectName); - object[] specificInterceptors; - specificInterceptors = GetAdvicesAndAdvisorsForObject(objectType, objectName, null); + IList specificInterceptors = GetAdvicesAndAdvisorsForObject(objectType, objectName, null); // proxy if we have advice or if a TargetSourceCreator wants to do some @@ -458,11 +458,11 @@ namespace Spring.Aop.Framework.AutoProxy /// the new object instance /// the name of the object /// targetSource returned by TargetSource property: - /// may be ignored. Will be null unless a custom target source is in use. + /// may be ignored. Will be null unless a custom target source is in use. /// an array of additional interceptors for the particular object; /// or an empty array if no additional interceptors but just the common ones; /// or null if no proxy at all, not even with the common interceptors. - protected abstract object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource); + protected abstract IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource); /// /// Create an AOP proxy for the given object. @@ -470,10 +470,10 @@ namespace Spring.Aop.Framework.AutoProxy /// Type of the object. /// The name of the object. /// The set of interceptors that is specific to this - /// object (may be empty but not null) + /// object (may be empty but not null) /// The target source for the proxy, already pre-configured to access the object. /// The AOP Proxy for the object. - protected virtual object CreateProxy(Type targetType, string targetName, object[] specificInterceptors, ITargetSource targetSource) + protected virtual object CreateProxy(Type targetType, string targetName, IList specificInterceptors, ITargetSource targetSource) { ProxyFactory proxyFactory = CreateProxyFactory(); // copy our properties (proxyTargetClass) inherited from ProxyConfig @@ -494,7 +494,7 @@ namespace Spring.Aop.Framework.AutoProxy } - IAdvisor[] advisors = BuildAdvisors(targetName, specificInterceptors); + IList advisors = BuildAdvisors(targetName, specificInterceptors); foreach (IAdvisor advisor in advisors) { @@ -529,14 +529,14 @@ namespace Spring.Aop.Framework.AutoProxy /// /// The name of the object. /// The set of interceptors that is specific to this - /// object (may be empty, but not null) + /// object (may be empty, but not null) /// The list of Advisors for the given object - protected virtual IAdvisor[] BuildAdvisors(string targetName, object[] specificInterceptors) + protected virtual IList BuildAdvisors(string targetName, IList specificInterceptors) { // handle prototypes correctly - IAdvisor[] commonInterceptors = ResolveInterceptorNames(); + IList commonInterceptors = ResolveInterceptorNames(); - ArrayList allInterceptors = new ArrayList(); + List allInterceptors = new List(); if (specificInterceptors != null) { allInterceptors.AddRange(specificInterceptors); @@ -544,26 +544,26 @@ namespace Spring.Aop.Framework.AutoProxy { if (applyCommonInterceptorsFirst) { - allInterceptors.InsertRange(0, commonInterceptors); + allInterceptors.InsertRange(0, commonInterceptors.Cast()); } else { - allInterceptors.AddRange(commonInterceptors); + allInterceptors.AddRange(commonInterceptors.Cast()); } } } if (logger.IsInfoEnabled) { - int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Length : 0; - int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Length : 0; + int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Count : 0; + int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Count : 0; logger.Info(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", targetName, nrOfCommonInterceptors, nrOfSpecificInterceptors)); } - IAdvisor[] advisors = new IAdvisor[allInterceptors.Count]; + List advisors = new List(allInterceptors.Count); for (int i = 0; i < allInterceptors.Count; i++) { - advisors[i] = advisorAdapterRegistry.Wrap(allInterceptors[i]); + advisors.Add(advisorAdapterRegistry.Wrap(allInterceptors[i])); } return advisors; } @@ -584,7 +584,7 @@ namespace Spring.Aop.Framework.AutoProxy #region Private Methods - private IAdvisor[] ResolveInterceptorNames() + private IList ResolveInterceptorNames() { List advisors = new List(); foreach (string name in interceptorNames) @@ -599,7 +599,7 @@ namespace Spring.Aop.Framework.AutoProxy advisors.Add(advisorAdapterRegistry.Wrap(next)); } } - return advisors.ToArray(); + return advisors; } #endregion @@ -659,7 +659,7 @@ namespace Spring.Aop.Framework.AutoProxy if (targetSource != null) { targetSourcedObjects.Add(objectName); - object[] specificInterceptors = GetAdvicesAndAdvisorsForObject(objectType, objectName, targetSource); + IList specificInterceptors = GetAdvicesAndAdvisorsForObject(objectType, objectName, targetSource); return CreateProxy(objectType, objectName, specificInterceptors, targetSource); } return null; @@ -687,8 +687,7 @@ namespace Spring.Aop.Framework.AutoProxy /// been set. /// Name of the object. /// The passed in PropertyValues - public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName) + public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName) { return pvs; } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs index 823be501..5c95302d 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractFilteringAutoProxyCreator.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; #endregion @@ -58,7 +59,7 @@ namespace Spring.Aop.Framework.AutoProxy /// Always to indicate, that the object shall be proxied. /// /// - protected override object[] GetAdvicesAndAdvisorsForObject( Type targetType, string targetName, ITargetSource customTargetSource ) + protected override IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) { return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS; } diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs index 45aebb98..5217ef44 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/DefaultAdvisorAutoProxyCreator.cs @@ -22,7 +22,7 @@ using System; using System.Collections; - +using System.Collections.Generic; using Spring.Objects.Factory; #endregion @@ -45,7 +45,7 @@ namespace Spring.Aop.Framework.AutoProxy public static readonly string SEPARATOR = "."; private bool usePrefix; private string advisorObjectNamePrefix; - private IList cachedAdvisors; + private IList cachedAdvisors; #region Properties @@ -108,7 +108,7 @@ namespace Spring.Aop.Framework.AutoProxy /// the type of the object to be advised /// the name of the object to be advised /// the list of candidate advisors - protected override IList FindCandidateAdvisors(Type targetType, string targetName) + protected override IList FindCandidateAdvisors(Type targetType, string targetName) { if (cachedAdvisors == null) { cachedAdvisors = base.FindCandidateAdvisors(targetType, targetName); diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs index 681b82a7..bcaa8451 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/IAdvisorRetrievalHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; namespace Spring.Aop.Framework.AutoProxy { @@ -13,6 +14,6 @@ namespace Spring.Aop.Framework.AutoProxy /// /// Get the list of advisor objects to apply on the target. /// - IList FindAdvisorObjects(Type targetType, string targetName); + IList FindAdvisorObjects(Type targetType, string targetName); } } \ No newline at end of file diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs index e442f9d6..3269320b 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/InheritanceBasedAopConfigurer.cs @@ -176,8 +176,8 @@ namespace Spring.Aop.Framework.AutoProxy /// public void PostProcessObjectFactory(IConfigurableListableObjectFactory factory) { - string[] objectDefinitionNames = factory.GetObjectDefinitionNames(); - for (int i = 0; i < objectDefinitionNames.Length; ++i) + IList objectDefinitionNames = factory.GetObjectDefinitionNames(); + for (int i = 0; i < objectDefinitionNames.Count; ++i) { string name = objectDefinitionNames[i]; if (IsObjectNameMatch(name)) @@ -260,7 +260,7 @@ namespace Spring.Aop.Framework.AutoProxy proxyFactory.Interfaces = Type.EmptyTypes; } - IAdvisor[] advisors = ResolveInterceptorNames(); + IList advisors = ResolveInterceptorNames(); foreach (IAdvisor advisor in advisors) { if (advisor is IIntroductionAdvisor) @@ -307,7 +307,7 @@ namespace Spring.Aop.Framework.AutoProxy #region Private Methods - private IAdvisor[] ResolveInterceptorNames() + private IList ResolveInterceptorNames() { List advisors = new List(); foreach (string name in interceptorNames) @@ -322,7 +322,7 @@ namespace Spring.Aop.Framework.AutoProxy advisors.Add(advisorAdapterRegistry.Wrap(next)); } } - return advisors.ToArray(); + return advisors; } #endregion diff --git a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs index 956da743..71196265 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectFactoryAdvisorRetrievalHelper.cs @@ -1,25 +1,24 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion using System; -using System.Collections; using System.Collections.Generic; using Common.Logging; @@ -38,7 +37,7 @@ namespace Spring.Aop.Framework.AutoProxy { private readonly ILog _log; private readonly IConfigurableListableObjectFactory _objectFactory; - private string[] _cachedObjectNames; + private List _cachedObjectNames; /// /// The object factory to lookup advisors from @@ -64,18 +63,18 @@ namespace Spring.Aop.Framework.AutoProxy /// the type of the object to be advised /// the name of the object to be advised /// A list of eligible instances - public virtual IList FindAdvisorObjects(Type targetType, string targetName) + public virtual IList FindAdvisorObjects(Type targetType, string targetName) { - string[] advisorNames = GetAdvisorCandidateNames(targetType, targetName); + IList advisorNames = GetAdvisorCandidateNames(targetType, targetName); List advisors = new List(); - if (advisorNames.Length == 0) + if (advisorNames.Count == 0) { return advisors; } - for (int i = 0; i < advisorNames.Length; i++) + for (int i = 0; i < advisorNames.Count; i++) { string name = advisorNames[i]; if (IsEligibleObject(name, targetType, targetName) && !_objectFactory.IsCurrentlyInCreation(name)) @@ -137,7 +136,7 @@ namespace Spring.Aop.Framework.AutoProxy /// the type of the object to be advised /// the name of the object to be advised /// a non-null string array of advisor candidate names - protected virtual string[] GetAdvisorCandidateNames(Type targetType, string targetName) + protected virtual IList GetAdvisorCandidateNames(Type targetType, string targetName) { if (_cachedObjectNames == null) { @@ -146,11 +145,11 @@ namespace Spring.Aop.Framework.AutoProxy if (_cachedObjectNames == null) { List candidateNameList = new List(); - string[] advisorCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors( _objectFactory, typeof(IAdvisor), true, false); + IList advisorCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors( _objectFactory, typeof(IAdvisor), true, false); candidateNameList.AddRange(advisorCandidateNames); - string[] advisorsCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_objectFactory, typeof(IAdvisors), true, false); + IList advisorsCandidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_objectFactory, typeof(IAdvisors), true, false); candidateNameList.AddRange(advisorsCandidateNames); - _cachedObjectNames = candidateNameList.ToArray(); + _cachedObjectNames = candidateNameList; } } } @@ -164,7 +163,7 @@ namespace Spring.Aop.Framework.AutoProxy /// /// the name of the candidate advisor /// the type of the object to be advised - /// the name of the object to be advised + /// the name of the object to be advised protected virtual bool IsEligibleObject(string advisorName, Type objectType, string objectName ) { bool containsObjectDefinition = this.ObjectFactory.ContainsObjectDefinition(advisorName); diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs index b4d0088a..9d0d95fa 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AbstractAopProxyFactory.cs @@ -31,7 +31,7 @@ namespace Spring.Aop.Framework.DynamicProxy { throw new AopConfigException("Cannot create IAopProxy with null ProxyConfig"); } - if (advisedSupport.Advisors.Length == 0 && advisedSupport.TargetSource == EmptyTargetSource.Empty) + if (advisedSupport.Advisors.Count == 0 && advisedSupport.TargetSource == EmptyTargetSource.Empty) { throw new AopConfigException("Cannot create IAopProxy with no advisors and no target source"); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs index 695cba78..7427af85 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/AdvisedProxy.cs @@ -165,8 +165,8 @@ namespace Spring.Aop.Framework.DynamicProxy this.m_targetType = advised.TargetSource.TargetType; // initialize introduction advice - this.m_introductions = new IAdvice[advised.Introductions.Length]; - for (int i = 0; i < advised.Introductions.Length; i++) + this.m_introductions = new IAdvice[advised.Introductions.Count]; + for (int i = 0; i < advised.Introductions.Count; i++) { this.m_introductions[i] = advised.Introductions[i].Advice; @@ -218,7 +218,7 @@ namespace Spring.Aop.Framework.DynamicProxy /// list of inteceptors for the specified method public IList GetInterceptors(Type targetType, MethodInfo method) { - if (m_advised.Advisors.Length == 0) + if (m_advised.Advisors.Count == 0) { return EmptyList; } @@ -252,17 +252,17 @@ namespace Spring.Aop.Framework.DynamicProxy get { return m_advised.ProxyTargetAttributes; } } - IAdvisor[] IAdvised.Advisors + IList IAdvised.Advisors { get { return m_advised.Advisors; } } - IIntroductionAdvisor[] IAdvised.Introductions + IList IAdvised.Introductions { get { return m_advised.Introductions; } } - Type[] IAdvised.Interfaces + IList IAdvised.Interfaces { get { return m_advised.Interfaces; } } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs index 1cb41710..79ab6917 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CachedAopProxyFactory.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Text; using System.Collections; @@ -123,27 +124,27 @@ namespace Spring.Aop.Framework.DynamicProxy /// private sealed class ProxyTypeCacheKey { - private sealed class HashCodeComparer : IComparer + private sealed class HashCodeComparer : IComparer { - public int Compare(object x, object y) + public int Compare(Type x, Type y) { return x.GetHashCode().CompareTo(y.GetHashCode()); } } - private static IComparer interfaceComparer = new HashCodeComparer(); + private static HashCodeComparer interfaceComparer = new HashCodeComparer(); private Type baseType; private Type targetType; - private Type[] interfaceTypes; + private List interfaceTypes; private bool proxyTargetAttributes; - public ProxyTypeCacheKey(Type baseType, Type targetType, Type[] interfaceTypes, bool proxyTargetAttributes) + public ProxyTypeCacheKey(Type baseType, Type targetType, IList interfaceTypes, bool proxyTargetAttributes) { this.baseType = baseType; this.targetType = targetType; - Array.Sort(interfaceTypes, interfaceComparer); // sort by GetHashcode()? to have a defined order - this.interfaceTypes = interfaceTypes; + this.interfaceTypes = new List(interfaceTypes); + this.interfaceTypes.Sort(interfaceComparer); // sort by GetHashcode()? to have a defined order this.proxyTargetAttributes = proxyTargetAttributes; } @@ -166,7 +167,7 @@ namespace Spring.Aop.Framework.DynamicProxy { return false; } - for (int i = 0; i < interfaceTypes.Length; i++) + for (int i = 0; i < interfaceTypes.Count; i++) { if (!Equals(interfaceTypes[i], proxyTypeCacheKey.interfaceTypes[i])) { @@ -184,7 +185,7 @@ namespace Spring.Aop.Framework.DynamicProxy { int result = baseType.GetHashCode(); result = 29*result + targetType.GetHashCode(); - for (int i = 0; i < interfaceTypes.Length; i++) + for (int i = 0; i < interfaceTypes.Count; i++) { result = 29 * result + interfaceTypes[i].GetHashCode(); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DefaultAopProxyFactory.cs b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DefaultAopProxyFactory.cs index 55ea6a04..052597e9 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DefaultAopProxyFactory.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DefaultAopProxyFactory.cs @@ -69,7 +69,7 @@ namespace Spring.Aop.Framework.DynamicProxy { IProxyTypeBuilder typeBuilder; if ((advisedSupport.ProxyTargetType) || - (advisedSupport.Interfaces.Length == 0)) + (advisedSupport.Interfaces.Count == 0)) { typeBuilder = new DecoratorAopProxyTypeBuilder(advisedSupport); } diff --git a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs index ea62cbed..f372be8b 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/IAdvised.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using AopAlliance.Aop; @@ -109,7 +110,7 @@ namespace Spring.Aop.Framework /// The collection of /// instances that have been applied to this proxy. /// - IAdvisor[] Advisors { get; } + IList Advisors { get; } /// /// Returns the collection of @@ -127,7 +128,7 @@ namespace Spring.Aop.Framework /// The collection of /// instances that have been applied to this proxy. /// - IIntroductionAdvisor[] Introductions { get; } + IList Introductions { get; } /// /// Returns the collection of interface s @@ -137,7 +138,7 @@ namespace Spring.Aop.Framework /// The collection of interface s /// to be (or that are being) proxied by this proxy. /// - Type[] Interfaces { get; } + IList Interfaces { get; } /// /// Returns the mapping of the proxied interface diff --git a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs index 2473a5e8..7e7b00d7 100644 --- a/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs +++ b/src/Spring/Spring.Aop/Aop/Framework/ProxyFactoryObject.cs @@ -397,7 +397,7 @@ namespace Spring.Aop.Framework { return this.singletonInstance.GetType(); } - else if (Interfaces.Length == 1) + else if (Interfaces.Count == 1) { return Interfaces[0]; } @@ -457,7 +457,7 @@ 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 introductionChain = FreshIntroductionChain(); AdvisedSupport copy = new AdvisedSupport(); copy.CopyConfigurationFrom(this, targetSource, advisorChain, introductionChain); @@ -625,16 +625,16 @@ namespace Spring.Aop.Framework /// Add all global interceptors and pointcuts. private void AddGlobalAdvisor(IListableObjectFactory objectFactory, string prefix) { - string[] globalAspectNames = + IList globalAspectNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvisors)); - string[] globalAdvisorNames = + IList globalAdvisorNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvisor)); - string[] globalInterceptorNames = + IList globalInterceptorNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IInterceptor)); List objects = new List(); Dictionary names = new Dictionary(); - for (int i = 0; i < globalAspectNames.Length; i++) + for (int i = 0; i < globalAspectNames.Count; i++) { string name = globalAspectNames[i]; if (name.StartsWith(prefix)) @@ -651,7 +651,7 @@ namespace Spring.Aop.Framework } } } - for (int i = 0; i < globalAdvisorNames.Length; i++) + for (int i = 0; i < globalAdvisorNames.Count; i++) { string name = globalAdvisorNames[i]; if (name.StartsWith(prefix)) @@ -665,7 +665,7 @@ namespace Spring.Aop.Framework } } } - for (int i = 0; i < globalInterceptorNames.Length; i++) + for (int i = 0; i < globalInterceptorNames.Count; i++) { string name = globalInterceptorNames[i]; if (name.StartsWith(prefix)) @@ -737,16 +737,16 @@ namespace Spring.Aop.Framework /// Add all global introductions. private void AddGlobalIntroduction(IListableObjectFactory objectFactory, string prefix) { - string[] globalAspectNames = + IList globalAspectNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvisors)); - string[] globalAdvisorNames = + IList globalAdvisorNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvisor)); - string[] globalIntroductionNames = + IList globalIntroductionNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(objectFactory, typeof(IAdvice)); ArrayList objects = new ArrayList(); Dictionary names = new Dictionary(); - for (int i = 0; i < globalAspectNames.Length; i++) + for (int i = 0; i < globalAspectNames.Count; i++) { string name = globalAspectNames[i]; if (name.StartsWith(prefix)) @@ -763,7 +763,7 @@ namespace Spring.Aop.Framework } } } - for (int i = 0; i < globalAdvisorNames.Length; i++) + for (int i = 0; i < globalAdvisorNames.Count; i++) { string name = globalAdvisorNames[i]; if (name.StartsWith(prefix)) @@ -777,7 +777,7 @@ namespace Spring.Aop.Framework } } } - for (int i = 0; i < globalIntroductionNames.Length; i++) + for (int i = 0; i < globalIntroductionNames.Count; i++) { string name = globalIntroductionNames[i]; if (name.StartsWith(prefix)) @@ -850,7 +850,7 @@ namespace Spring.Aop.Framework /// private IList FreshAdvisorChain() { - IAdvisor[] advisors = Advisors; + IList advisors = Advisors; List freshAdvisors = new List(); foreach (IAdvisor advisor in advisors) { @@ -881,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; - List freshIntroductions = new List(); + IList introductions = Introductions; + List freshIntroductions = new List(); foreach (IIntroductionAdvisor introduction in introductions) { if (introduction is PrototypePlaceholder) @@ -899,7 +899,7 @@ namespace Spring.Aop.Framework AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory"); object introductionObject = this.objectFactory.GetObject(pa.ObjectName); - IAdvisor freshIntroduction = NamedObjectToIntroduction(introductionObject); + IIntroductionAdvisor freshIntroduction = NamedObjectToIntroduction(introductionObject); freshIntroductions.Add(freshIntroduction); } else diff --git a/src/Spring/Spring.Aop/Spring.Aop.2008.csproj b/src/Spring/Spring.Aop/Spring.Aop.2008.csproj index 6c3d3cb5..e12fc8cd 100644 --- a/src/Spring/Spring.Aop/Spring.Aop.2008.csproj +++ b/src/Spring/Spring.Aop/Spring.Aop.2008.csproj @@ -93,6 +93,9 @@ System + + 3.5 + System.Data diff --git a/src/Spring/Spring.Core/Context/IMessageSourceResolvable.cs b/src/Spring/Spring.Core/Context/IMessageSourceResolvable.cs index 35832428..d871adb6 100644 --- a/src/Spring/Spring.Core/Context/IMessageSourceResolvable.cs +++ b/src/Spring/Spring.Core/Context/IMessageSourceResolvable.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Globalization; #endregion @@ -46,16 +47,16 @@ namespace Spring.Context /// Return the codes to be used to resolve this message, in the order /// that they are to be tried. /// - /// - ///

- /// The last code will therefore be the default one. - ///

- ///
+ /// + ///

+ /// The last code will therefore be the default one. + ///

+ ///
/// /// A array of codes which are associated /// with this message. /// - string[] GetCodes(); + IList GetCodes(); /// /// Return the array of arguments to be used to resolve this message. diff --git a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs index 42e31143..85944326 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs @@ -513,7 +513,7 @@ namespace Spring.Context.Support } } - IDictionary objectMap = objectFactory.GetObjectsOfType(true, false); + IDictionary objectMap = objectFactory.GetObjects(true, false); List registryPostProcessorObjects = new List(objectMap.Values); registryPostProcessorObjects.Sort(new OrderComparator()); @@ -547,11 +547,8 @@ 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! List factoryProcessorNames = new List(); - string[] names = GetObjectNamesForType(typeof(IObjectFactoryPostProcessor), true, false); - foreach (string name in names) - { - factoryProcessorNames.Add(name); - } + IList names = GetObjectNamesForType(typeof(IObjectFactoryPostProcessor), true, false); + factoryProcessorNames.AddRange(names); // Separate between ObjectFactoryPostProcessors that implement PriorityOrdered, // Ordered, and the rest. @@ -621,7 +618,7 @@ namespace Spring.Context.Support // Now will find any additional IObjectFactoryPostProcessors that implement IPriorityOrdered that may have been // resolved due to using TypeAlias - string[] factoryProcessorNamesAfterTypeAlias = GetObjectNamesForType(typeof(IObjectFactoryPostProcessor), true, false); + IList factoryProcessorNamesAfterTypeAlias = GetObjectNamesForType(typeof(IObjectFactoryPostProcessor), true, false); priorityOrderedFactoryProcessors.Clear(); foreach (string factoryProcessorName in factoryProcessorNamesAfterTypeAlias) { @@ -649,7 +646,7 @@ namespace Spring.Context.Support private void RegisterObjectPostProcessors(IConfigurableListableObjectFactory objectFactory) { RefreshObjectPostProcessorChecker(objectFactory); - IDictionary dict = GetObjectsOfType(true, false); + IDictionary dict = GetObjects(true, false); List objectProcessors = new List(dict.Values); // objectProcessors.Sort(new OrderComparator()); foreach (IObjectPostProcessor objectPostProcessor in objectProcessors) @@ -675,7 +672,7 @@ namespace Spring.Context.Support /// private void RefreshObjectPostProcessorChecker(IConfigurableListableObjectFactory objectFactory) { - int registeredObjectPostProcessorCount = GetObjectNamesForType(typeof(IObjectPostProcessor), true, false).Length; + int registeredObjectPostProcessorCount = GetObjectNamesForType(typeof(IObjectPostProcessor), true, false).Count; int objectPostProcessorCount = ObjectFactory.ObjectPostProcessorCount + 1 + registeredObjectPostProcessorCount; ((ObjectPostProcessorChecker)_defaultObjectPostProcessors[0]).Reset(objectFactory, objectPostProcessorCount); @@ -733,7 +730,7 @@ namespace Spring.Context.Support #endregion } - ICollection interestedParties = GetObjectsOfType(true, false).Values; + ICollection interestedParties = GetObjects(true, false).Values; foreach (IEventRegistryAware party in interestedParties) { party.EventRegistry = EventRegistry; @@ -856,7 +853,7 @@ namespace Spring.Context.Support private void RefreshApplicationEventListeners() { - ICollection listeners = GetObjectsOfType(true, false).Values; + ICollection listeners = GetObjects(true, false).Values; foreach (IApplicationEventListener applicationListener in listeners) { EventRegistry.Subscribe(applicationListener); @@ -1165,7 +1162,7 @@ namespace Spring.Context.Support get { IConfigurableListableObjectFactory objectFactory = ObjectFactory; - string[] objectNames = objectFactory.SingletonNames; + IList objectNames = objectFactory.SingletonNames; IDictionary lifeCycleObjects = new Dictionary(); foreach (string objectName in objectNames) { @@ -1232,7 +1229,7 @@ namespace Spring.Context.Support /// are defined. /// /// - public string[] GetObjectNamesForType(Type type) + public IList GetObjectNamesForType(Type type) { return ObjectFactory.GetObjectNamesForType(type); } @@ -1260,7 +1257,7 @@ namespace Spring.Context.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType() + public IList GetObjectNames() { return GetObjectNamesForType(typeof(T)); } @@ -1286,8 +1283,7 @@ namespace Spring.Context.Support /// are defined. /// /// - public string[] GetObjectNamesForType( - Type type, bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects) { return ObjectFactory.GetObjectNamesForType(type, includePrototypes, includeFactoryObjects); } @@ -1327,7 +1323,7 @@ namespace Spring.Context.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType(bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNames(bool includePrototypes, bool includeFactoryObjects) { return GetObjectNamesForType(typeof(T), includePrototypes, includeFactoryObjects); } @@ -1340,7 +1336,7 @@ namespace Spring.Context.Support /// are defined. /// /// - public string[] GetObjectDefinitionNames() + public IList GetObjectDefinitionNames() { return ObjectFactory.GetObjectDefinitionNames(); } @@ -1442,9 +1438,9 @@ namespace Spring.Context.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType() + public IDictionary GetObjects() { - return ObjectFactory.GetObjectsOfType(true, true); + return ObjectFactory.GetObjects(true, true); } /// @@ -1506,9 +1502,9 @@ namespace Spring.Context.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects) + public IDictionary GetObjects(bool includePrototypes, bool includeFactoryObjects) { - return ObjectFactory.GetObjectsOfType(includePrototypes, includeFactoryObjects); + return ObjectFactory.GetObjects(includePrototypes, includeFactoryObjects); } /// @@ -1542,13 +1538,13 @@ namespace Spring.Context.Support /// public T GetObject() { - string[] objectNamesForType = GetObjectNamesForType(typeof(T)); - if ((objectNamesForType == null) || (objectNamesForType.Length == 0)) + IList objectNamesForType = GetObjectNamesForType(typeof(T)); + if ((objectNamesForType == null) || (objectNamesForType.Count == 0)) { throw new NoSuchObjectDefinitionException(typeof(T).FullName, "Requested Type not Defined in the Context."); } - if (objectNamesForType.Length > 1) + if (objectNamesForType.Count > 1) { throw new ObjectDefinitionStoreException(string.Format("More than one definition for {0} found in the Context.", typeof(T).FullName)); } @@ -1624,7 +1620,7 @@ namespace Spring.Context.Support /// If there's no such object definition. /// /// - public string[] GetAliases(string name) + public IList GetAliases(string name) { return ObjectFactory.GetAliases(name); } diff --git a/src/Spring/Spring.Core/Context/Support/AbstractMessageSource.cs b/src/Spring/Spring.Core/Context/Support/AbstractMessageSource.cs index 024513fd..462e71bc 100644 --- a/src/Spring/Spring.Core/Context/Support/AbstractMessageSource.cs +++ b/src/Spring/Spring.Core/Context/Support/AbstractMessageSource.cs @@ -19,6 +19,7 @@ #endregion using System; +using System.Collections.Generic; using System.Globalization; using Common.Logging; @@ -282,21 +283,21 @@ namespace Spring.Context.Support /// public string GetMessage(IMessageSourceResolvable resolvable, CultureInfo culture) { - string[] codes = resolvable.GetCodes(); + IList codes = resolvable.GetCodes(); if (codes == null) codes = new string[0]; - for (int i = 0; i < codes.Length; i++) + for (int i = 0; i < codes.Count; i++) { string msg = GetMessageInternal(codes[i], resolvable.GetArguments(), culture); if (msg != null) return msg; } if (resolvable.DefaultMessage != null) return RenderDefaultMessage(resolvable.DefaultMessage, resolvable.GetArguments(), culture); - if (codes.Length > 0) + if (codes.Count > 0) { string fallback = GetDefaultMessage(codes[0]); if (fallback != null) return fallback; } - throw new NoSuchMessageException(codes.Length > 0 ? codes[codes.Length - 1] : null, culture); + throw new NoSuchMessageException(codes.Count > 0 ? codes[codes.Count - 1] : null, culture); } /// diff --git a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs index bee696a3..c97613aa 100644 --- a/src/Spring/Spring.Core/Context/Support/ContextHandler.cs +++ b/src/Spring/Spring.Core/Context/Support/ContextHandler.cs @@ -282,7 +282,7 @@ namespace Spring.Context.Support bool caseSensitive = GetCaseSensitivity(contextElement); // get resource-list - string[] resources = GetResources(contextElement); + IList resources = GetResources(contextElement); // finally create the context instance context = InstantiateContext(parentContext, configContext, contextName, contextType, caseSensitive, resources); @@ -293,7 +293,7 @@ namespace Spring.Context.Support } // get and create child context definitions - XmlNode[] childContexts = GetChildContexts(contextElement); + IList childContexts = GetChildContexts(contextElement); CreateChildContexts(context, configContext, childContexts); if (Log.IsDebugEnabled) Log.Debug( string.Format("context '{0}' created for name '{1}'", context, contextName) ); @@ -309,15 +309,15 @@ namespace Spring.Context.Support throw; } return context; - } - - /// - /// Create all child-contexts in the given for the given context. - /// - /// The parent context to use - /// The current configContext - /// The list of child context elements - protected virtual void CreateChildContexts(IApplicationContext parentContext, object configContext, XmlNode[] childContexts) + } + + /// + /// Create all child-contexts in the given for the given context. + /// + /// The parent context to use + /// The current configContext + /// The list of child context elements + protected virtual void CreateChildContexts(IApplicationContext parentContext, object configContext, IList childContexts) { // create child contexts for 'the most recently created context'... foreach (XmlNode childContext in childContexts) @@ -329,18 +329,18 @@ namespace Spring.Context.Support /// /// Instantiates a new context. /// - protected virtual IApplicationContext InstantiateContext(IApplicationContext parentContext, object configContext, string contextName, Type contextType, bool caseSensitive, string[] resources) + protected virtual IApplicationContext InstantiateContext(IApplicationContext parentContext, object configContext, string contextName, Type contextType, bool caseSensitive, IList resources) { IApplicationContext context; ContextInstantiator instantiator; if (parentContext == null) { - instantiator = new RootContextInstantiator(contextType, contextName, caseSensitive, resources); + instantiator = new RootContextInstantiator(contextType, contextName, caseSensitive, new List(resources).ToArray()); } else - { - instantiator = new DescendantContextInstantiator(parentContext, contextType, contextName, caseSensitive, resources); + { + instantiator = new DescendantContextInstantiator(parentContext, contextType, contextName, caseSensitive, new List(resources).ToArray()); } if (IsLazy) @@ -446,7 +446,7 @@ namespace Spring.Context.Support /// Returns the array of resources containing object definitions for /// this context. /// - private string[] GetResources( XmlElement contextElement ) + private IList GetResources( XmlElement contextElement ) { List resourceNodes = new List(contextElement.ChildNodes.Count); foreach (XmlNode possibleResourceNode in contextElement.ChildNodes) @@ -462,13 +462,13 @@ namespace Spring.Context.Support } } } - return resourceNodes.ToArray(); + return resourceNodes; } /// /// Returns the array of child contexts for this context. /// - private XmlNode[] GetChildContexts(XmlElement contextElement) + private IList GetChildContexts(XmlElement contextElement) { List contextNodes = new List(contextElement.ChildNodes.Count); foreach (XmlNode possibleContextNode in contextElement.ChildNodes) @@ -480,7 +480,7 @@ namespace Spring.Context.Support contextNodes.Add(possibleContextElement); } } - return contextNodes.ToArray(); + return contextNodes; } #region Inner Class : ContextInstantiator @@ -528,7 +528,7 @@ namespace Spring.Context.Support get { return _caseSensitive; } } - protected string[] Resources + protected IList Resources { get { return _resources; } } @@ -536,7 +536,7 @@ namespace Spring.Context.Support private Type _contextType; private string _contextName; private bool _caseSensitive; - private string[] _resources; + private IList _resources; } #endregion diff --git a/src/Spring/Spring.Core/Context/Support/DefaultMessageSourceResolvable.cs b/src/Spring/Spring.Core/Context/Support/DefaultMessageSourceResolvable.cs index ca8fbeb6..5f86f20f 100644 --- a/src/Spring/Spring.Core/Context/Support/DefaultMessageSourceResolvable.cs +++ b/src/Spring/Spring.Core/Context/Support/DefaultMessageSourceResolvable.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Globalization; using Spring.Util; @@ -44,7 +45,7 @@ namespace Spring.Context.Support [Serializable] public class DefaultMessageSourceResolvable : IMessageSourceResolvable { - private string[] codes; + private IList codes; private object[] arguments; private string defaultMessage; @@ -97,7 +98,7 @@ namespace Spring.Context.Support /// The default message used if no code could be resolved. /// public DefaultMessageSourceResolvable( - string[] codes, object[] arguments, string defaultMessage) + IList codes, object[] arguments, string defaultMessage) { this.codes = codes; this.arguments = arguments; @@ -141,9 +142,9 @@ namespace Spring.Context.Support { get { - if (codes != null && codes.Length > 0) + if (codes != null && codes.Count > 0) { - return codes[codes.Length - 1]; + return codes[codes.Count - 1]; } else { @@ -181,16 +182,16 @@ namespace Spring.Context.Support #region IMessageSourceResolvable Members - /// - /// Return the codes to be used to resolve this message, in the order - /// that they are to be tried. - /// - /// - /// A array of codes which are associated - /// with this message. - /// - /// - public string[] GetCodes() + /// + /// Return the codes to be used to resolve this message, in the order + /// that they are to be tried. + /// + /// + /// A array of codes which are associated + /// with this message. + /// + /// + public IList GetCodes() { return codes; } diff --git a/src/Spring/Spring.Core/Context/Support/DelegatingMessageSource.cs b/src/Spring/Spring.Core/Context/Support/DelegatingMessageSource.cs index ad75cdfd..03bddaa1 100644 --- a/src/Spring/Spring.Core/Context/Support/DelegatingMessageSource.cs +++ b/src/Spring/Spring.Core/Context/Support/DelegatingMessageSource.cs @@ -20,6 +20,7 @@ #region Imports +using System.Collections.Generic; using System.Globalization; using Spring.Util; @@ -352,8 +353,8 @@ namespace Spring.Context.Support { return resolvable.DefaultMessage; } - string[] codes = resolvable.GetCodes(); - string code = (codes != null && codes.Length > 0 ? codes[0] : string.Empty); + IList codes = resolvable.GetCodes(); + string code = (codes != null && codes.Count > 0 ? codes[0] : string.Empty); throw new NoSuchMessageException(code, culture); } diff --git a/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs b/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs index cfdf4b20..5eade196 100644 --- a/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs +++ b/src/Spring/Spring.Core/Core/TypeResolution/TypeResolutionUtils.cs @@ -21,7 +21,6 @@ #region Imports using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; @@ -123,7 +122,7 @@ namespace Spring.Core.TypeResolution /// If (or any of its elements ) is /// . /// - public static Type[] ResolveInterfaceArray(string[] interfaceNames) + public static IList ResolveInterfaceArray(string[] interfaceNames) { AssertUtils.ArgumentNotNull(interfaceNames, "interfaceNames"); @@ -144,7 +143,7 @@ namespace Spring.Core.TypeResolution interfaces.Add(resolvedInterface); interfaces.AddRange(resolvedInterface.GetInterfaces()); } - return interfaces.ToArray(); + return interfaces; } #region MethodMatch diff --git a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs index 332b273a..e5aae7c5 100644 --- a/src/Spring/Spring.Core/Expressions/ConstructorNode.cs +++ b/src/Spring/Spring.Core/Expressions/ConstructorNode.cs @@ -179,15 +179,15 @@ namespace Spring.Expressions private static ConstructorInfo GetBestConstructor(Type type, object[] argValues) { - ConstructorInfo[] candidates = GetCandidateConstructors(type, argValues.Length); - if (candidates.Length > 0) + IList candidates = GetCandidateConstructors(type, argValues.Length); + if (candidates.Count > 0) { return ReflectionUtils.GetConstructorByArgumentValues(candidates, argValues); } return null; } - private static ConstructorInfo[] GetCandidateConstructors(Type type, int argCount) + private static IList GetCandidateConstructors(Type type, int argCount) { ConstructorInfo[] ctors = type.GetConstructors(BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic); List matches = new List(); @@ -209,7 +209,7 @@ namespace Spring.Expressions } } - return matches.ToArray(); + return matches; } } diff --git a/src/Spring/Spring.Core/Expressions/MethodNode.cs b/src/Spring/Spring.Core/Expressions/MethodNode.cs index e7f0d99b..079b71d6 100644 --- a/src/Spring/Spring.Core/Expressions/MethodNode.cs +++ b/src/Spring/Spring.Core/Expressions/MethodNode.cs @@ -234,8 +234,8 @@ namespace Spring.Expressions catch (AmbiguousMatchException) { - MethodInfo[] overloads = GetCandidateMethods(type, methodName, bindingFlags, argValues.Length); - if (overloads.Length > 0) + IList overloads = GetCandidateMethods(type, methodName, bindingFlags, argValues.Length); + if (overloads.Count > 0) { mi = ReflectionUtils.GetMethodByArgumentValues(overloads, argValues); } @@ -245,7 +245,7 @@ namespace Spring.Expressions - private static MethodInfo[] GetCandidateMethods(Type type, string methodName, BindingFlags bindingFlags, int argCount) + private static IList GetCandidateMethods(Type type, string methodName, BindingFlags bindingFlags, int argCount) { MethodInfo[] methods = type.GetMethods(bindingFlags | BindingFlags.FlattenHierarchy); List matches = new List(); @@ -270,7 +270,7 @@ namespace Spring.Expressions } } - return matches.ToArray(); + return matches; } // used to calculate signature hash while caring for arg positions diff --git a/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs index 19e174ba..2f822123 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Attributes/RequiredAttributeObjectPostProcessor.cs @@ -107,8 +107,7 @@ namespace Spring.Objects.Factory.Attributes /// /// If a required property value has not been specified /// in the configuration metadata. - public override IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName) + public override IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName) { if (!validatedObjectNames.Contains(objectName)) { @@ -124,7 +123,7 @@ namespace Spring.Objects.Factory.Attributes if (invalidProperties.Count != 0) { throw new ObjectInitializationException( - BuildExceptionMessage(invalidProperties.ToArray(), objectName)); + BuildExceptionMessage(invalidProperties, objectName)); } validatedObjectNames.Add(objectName); } @@ -154,9 +153,9 @@ namespace Spring.Objects.Factory.Attributes /// The list of names of invalid properties. /// Name of the object. /// The exception message - private string BuildExceptionMessage(string[] invalidProperties, ICloneable objectName) + private string BuildExceptionMessage(IList invalidProperties, ICloneable objectName) { - int size = invalidProperties.Length; + int size = invalidProperties.Count; StringBuilder sb = new StringBuilder(); sb.Append(size == 1 ? "Property" : "Properties"); for (int i=0; i < size; i++) diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/IInstantiationAwareObjectPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Config/IInstantiationAwareObjectPostProcessor.cs index b9d5673c..f7a44bab 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/IInstantiationAwareObjectPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/IInstantiationAwareObjectPostProcessor.cs @@ -19,6 +19,7 @@ #endregion using System; +using System.Collections.Generic; using System.Reflection; namespace Spring.Objects.Factory.Config { @@ -105,26 +106,25 @@ namespace Spring.Objects.Factory.Config { /// invoked on this object instance. bool PostProcessAfterInstantiation(object objectInstance, string objectName); - /// - /// Post-process the given property values before the factory applies them - /// to the given object. - /// - /// Allows for checking whether all dependencies have been - /// satisfied, for example based on a "Required" annotation on bean property setters. - /// Also allows for replacing the property values to apply, typically through - /// creating a new MutablePropertyValues instance based on the original PropertyValues, - /// adding or removing specific values. - /// - /// - /// The property values that the factory is about to apply (never null). - /// he relevant property infos for the target object (with ignored - /// dependency types - which the factory handles specifically - already filtered out) - /// The object instance created, but whose properties have not yet - /// been set. - /// Name of the object. - /// The actual property values to apply to the given object (can be the - /// passed-in PropertyValues instances0 or null to skip property population. - IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName); + /// + /// Post-process the given property values before the factory applies them + /// to the given object. + /// + /// Allows for checking whether all dependencies have been + /// satisfied, for example based on a "Required" annotation on bean property setters. + /// Also allows for replacing the property values to apply, typically through + /// creating a new MutablePropertyValues instance based on the original PropertyValues, + /// adding or removing specific values. + /// + /// + /// The property values that the factory is about to apply (never null). + /// he relevant property infos for the target object (with ignored + /// dependency types - which the factory handles specifically - already filtered out) + /// The object instance created, but whose properties have not yet + /// been set. + /// Name of the object. + /// The actual property values to apply to the given object (can be the + /// passed-in PropertyValues instances0 or null to skip property population. + IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName); } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/IObjectDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Config/IObjectDefinition.cs index f61d8f1f..81f19b3d 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/IObjectDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/IObjectDefinition.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; #endregion @@ -178,7 +179,7 @@ namespace Spring.Objects.Factory.Config /// preparation on startup. ///

/// - string[] DependsOn { get; } + IList DependsOn { get; } /// /// The name of the initializer method. diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ISingletonObjectRegistry.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ISingletonObjectRegistry.cs index b2f0a4c7..e1019486 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/ISingletonObjectRegistry.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/ISingletonObjectRegistry.cs @@ -18,6 +18,8 @@ #endregion +using System.Collections.Generic; + namespace Spring.Objects.Factory.Config { /// @@ -138,7 +140,7 @@ namespace Spring.Objects.Factory.Config /// /// /// - string[] SingletonNames + IList SingletonNames { get; } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/InstantiationAwareObjectPostProcessorAdapter.cs b/src/Spring/Spring.Core/Objects/Factory/Config/InstantiationAwareObjectPostProcessorAdapter.cs index d96f4557..2d357fad 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/InstantiationAwareObjectPostProcessorAdapter.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/InstantiationAwareObjectPostProcessorAdapter.cs @@ -19,6 +19,7 @@ #endregion using System; +using System.Collections.Generic; using System.Reflection; namespace Spring.Objects.Factory.Config @@ -153,8 +154,7 @@ namespace Spring.Objects.Factory.Config /// Name of the object. /// The actual property values to apply to the given object (can be the /// passed-in PropertyValues instances0 or null to skip property population. - public virtual IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName) + public virtual IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName) { return pvs; } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionHolder.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionHolder.cs index 082842b5..4fa884b9 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionHolder.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionHolder.cs @@ -21,7 +21,8 @@ #region Imports using System; -using Spring.Objects.Factory.Config; +using System.Collections.Generic; + using Spring.Objects.Factory.Xml; using Spring.Util; @@ -56,7 +57,7 @@ namespace Spring.Objects.Factory.Config { private IObjectDefinition objectDefinition; private string objectName; - private string[] aliases; + private IList aliases; #region Constructor () / Destructor @@ -87,11 +88,11 @@ namespace Spring.Objects.Factory.Config /// Any aliases for the supplied /// public ObjectDefinitionHolder( - IObjectDefinition definition, string name, string[] aliases) + IObjectDefinition definition, string name, IList aliases) { this.objectDefinition = definition; this.objectName = name; - this.aliases = aliases == null ? StringUtils.EmptyStrings : aliases; + this.aliases = aliases ?? new List(0); } #endregion @@ -126,7 +127,7 @@ namespace Spring.Objects.Factory.Config /// array will be returned. ///

/// - public string[] Aliases + public IList Aliases { get { return aliases; } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs index 1b8a4b81..31f23ce4 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs @@ -115,7 +115,7 @@ namespace Spring.Objects.Factory.Config MutablePropertyValues pvs = objectDefinition.PropertyValues; if (pvs != null) { - for (int j = 0; j < pvs.PropertyValues.Length; j++) + for (int j = 0; j < pvs.PropertyValues.Count; j++) { PropertyValue pv = pvs.PropertyValues[j]; object newVal = ResolveValue(pv.Value); diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs index 88ea1636..017d5f40 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/PropertyPlaceholderConfigurer.cs @@ -21,10 +21,12 @@ #region Imports using System; -using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; + using Common.Logging; + using Spring.Collections; #endregion @@ -228,10 +230,10 @@ namespace Spring.Objects.Factory.Config protected override void ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) { PlaceholderResolveHandlerAdapter resolveAdapter = new PlaceholderResolveHandlerAdapter(this, props); - ObjectDefinitionVisitor visitor = new ObjectDefinitionVisitor(new ObjectDefinitionVisitor.ResolveHandler(resolveAdapter.ParseAndResolveVariables)); + ObjectDefinitionVisitor visitor = new ObjectDefinitionVisitor(resolveAdapter.ParseAndResolveVariables); - string[] objectDefinitionNames = factory.GetObjectDefinitionNames(); - for (int i = 0; i < objectDefinitionNames.Length; ++i) + IList objectDefinitionNames = factory.GetObjectDefinitionNames(); + for (int i = 0; i < objectDefinitionNames.Count; ++i) { string name = objectDefinitionNames[i]; IObjectDefinition definition = factory.GetObjectDefinition(name); diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs b/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs index b38ff170..bbb18561 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/VariablePlaceholderConfigurer.cs @@ -20,6 +20,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Globalization; using Common.Logging; using Spring.Collections; @@ -245,8 +246,8 @@ namespace Spring.Objects.Factory.Config TextProcessor tp = new TextProcessor(this, compositeVariableSource); ObjectDefinitionVisitor visitor = new ObjectDefinitionVisitor(new ObjectDefinitionVisitor.ResolveHandler(tp.ParseAndResolveVariables)); - string[] objectDefinitionNames = factory.GetObjectDefinitionNames(); - for (int i = 0; i < objectDefinitionNames.Length; ++i) + IList objectDefinitionNames = factory.GetObjectDefinitionNames(); + for (int i = 0; i < objectDefinitionNames.Count; ++i) { string name = objectDefinitionNames[i]; IObjectDefinition definition = factory.GetObjectDefinition( name ); diff --git a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs index 9866b06b..c071a342 100644 --- a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs @@ -86,141 +86,141 @@ namespace Spring.Objects.Factory /// int ObjectDefinitionCount { get; } - - /// - /// Return the names of all objects defined in this factory. - /// - /// - /// The names of all objects defined in this factory, or an empty array if none - /// are defined. - /// - string[] GetObjectDefinitionNames(); - /// - /// Return the names of objects matching the given - /// (including subclasses), judging from the object definitions. - /// - /// - ///

- /// Does consider objects created by s, - /// or rather it considers the type of objects created by - /// (which means that - /// s will be instantiated). - ///

- ///

- /// Does not consider any hierarchy this factory may participate in. - ///

- ///
- /// - /// The (class or interface) to match, or - /// for all object names. - /// - /// - /// The names of all objects defined in this factory, or an empty array if none - /// are defined. - /// - string[] GetObjectNamesForType(Type type); + /// + /// Return the names of all objects defined in this factory. + /// + /// + /// The names of all objects defined in this factory, or an empty array if none + /// are defined. + /// + IList GetObjectDefinitionNames(); + + /// + /// Return the names of objects matching the given + /// (including subclasses), judging from the object definitions. + /// + /// + ///

+ /// Does consider objects created by s, + /// or rather it considers the type of objects created by + /// (which means that + /// s will be instantiated). + ///

+ ///

+ /// Does not consider any hierarchy this factory may participate in. + ///

+ ///
+ /// + /// The (class or interface) to match, or + /// for all object names. + /// + /// + /// The names of all objects defined in this factory, or an empty array if none + /// are defined. + /// + IList GetObjectNamesForType(Type type); - /// - /// Return the names of objects matching the given - /// (including subclasses), judging from the object definitions. - /// - /// - ///

- /// Does consider objects created by s, - /// or rather it considers the type of objects created by - /// (which means that - /// s will be instantiated). - ///

- ///

- /// Does not consider any hierarchy this factory may participate in. - ///

- ///
- /// - /// The (class or interface) to match, or - /// for all object names. - /// - /// - /// The names of all objects defined in this factory, or an empty array if none - /// are defined. - /// - string[] GetObjectNamesForType(); + /// + /// Return the names of objects matching the given + /// (including subclasses), judging from the object definitions. + /// + /// + ///

+ /// Does consider objects created by s, + /// or rather it considers the type of objects created by + /// (which means that + /// s will be instantiated). + ///

+ ///

+ /// Does not consider any hierarchy this factory may participate in. + ///

+ ///
+ /// + /// The (class or interface) to match, or + /// for all object names. + /// + /// + /// The names of all objects defined in this factory, or an empty array if none + /// are defined. + /// + IList GetObjectNames(); - /// - /// Return the names of objects matching the given - /// (including subclasses), judging from the object definitions. - /// - /// - ///

- /// Does consider objects created by s, - /// or rather it considers the type of objects created by - /// (which means that - /// s will be instantiated). - ///

- ///

- /// Does not consider any hierarchy this factory may participate in. - /// Use - /// to include beans in ancestor factories too. - /// <p>Note: Does <i>not</i> ignore singleton objects that have been registered - /// by other means than bean definitions. - ///

- ///
- /// - /// The (class or interface) to match, or - /// for all object names. - /// - /// - /// Whether to include prototype objects too or just singletons (also applies to - /// s). - /// - /// - /// Whether to include s too - /// or just normal objects. - /// - /// - /// The names of all objects defined in this factory, or an empty array if none - /// are defined. - /// - string[] GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects); + /// + /// Return the names of objects matching the given + /// (including subclasses), judging from the object definitions. + /// + /// + ///

+ /// Does consider objects created by s, + /// or rather it considers the type of objects created by + /// (which means that + /// s will be instantiated). + ///

+ ///

+ /// Does not consider any hierarchy this factory may participate in. + /// Use + /// to include beans in ancestor factories too. + /// <p>Note: Does <i>not</i> ignore singleton objects that have been registered + /// by other means than bean definitions. + ///

+ ///
+ /// + /// The (class or interface) to match, or + /// for all object names. + /// + /// + /// Whether to include prototype objects too or just singletons (also applies to + /// s). + /// + /// + /// Whether to include s too + /// or just normal objects. + /// + /// + /// The names of all objects defined in this factory, or an empty array if none + /// are defined. + /// + IList GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects); - /// - /// Return the names of objects matching the given - /// (including subclasses), judging from the object definitions. - /// - /// - ///

- /// Does consider objects created by s, - /// or rather it considers the type of objects created by - /// (which means that - /// s will be instantiated). - ///

- ///

- /// Does not consider any hierarchy this factory may participate in. - /// Use - /// to include beans in ancestor factories too. - /// <p>Note: Does <i>not</i> ignore singleton objects that have been registered - /// by other means than bean definitions. - ///

- ///
- /// - /// The (class or interface) to match, or - /// for all object names. - /// - /// - /// Whether to include prototype objects too or just singletons (also applies to - /// s). - /// - /// - /// Whether to include s too - /// or just normal objects. - /// - /// - /// The names of all objects defined in this factory, or an empty array if none - /// are defined. - /// - string[] GetObjectNamesForType(bool includePrototypes, bool includeFactoryObjects); + /// + /// Return the names of objects matching the given + /// (including subclasses), judging from the object definitions. + /// + /// + ///

+ /// Does consider objects created by s, + /// or rather it considers the type of objects created by + /// (which means that + /// s will be instantiated). + ///

+ ///

+ /// Does not consider any hierarchy this factory may participate in. + /// Use + /// to include beans in ancestor factories too. + /// <p>Note: Does <i>not</i> ignore singleton objects that have been registered + /// by other means than bean definitions. + ///

+ ///
+ /// + /// The (class or interface) to match, or + /// for all object names. + /// + /// + /// Whether to include prototype objects too or just singletons (also applies to + /// s). + /// + /// + /// Whether to include s too + /// or just normal objects. + /// + /// + /// The names of all objects defined in this factory, or an empty array if none + /// are defined. + /// + IList GetObjectNames(bool includePrototypes, bool includeFactoryObjects); /// /// Return the object instances that match the given object @@ -278,7 +278,7 @@ namespace Spring.Objects.Factory /// /// If the objects could not be created. /// - IDictionary GetObjectsOfType(); + IDictionary GetObjects(); /// /// Return the object instances that match the given object @@ -334,7 +334,7 @@ namespace Spring.Objects.Factory /// /// If the objects could not be created. /// - IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects); + IDictionary GetObjects(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/IObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs index dbfaadae..aff582d0 100644 --- a/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; #endregion @@ -209,21 +210,21 @@ namespace Spring.Objects.Factory /// True if an object with the given name is defined. bool ContainsObject(string name); - /// - /// Return the aliases for the given object name, if defined. - /// - /// - /// - /// Will ask the parent factory if the object cannot be found in this factory - /// instance. - /// - /// - /// The object name to check for aliases. - /// The aliases, or an empty array if none. - /// - /// If there's no such object definition. - /// - string[] GetAliases(string name); + /// + /// Return the aliases for the given object name, if defined. + /// + /// + /// + /// Will ask the parent factory if the object cannot be found in this factory + /// instance. + /// + /// + /// The object name to check for aliases. + /// The aliases, or an empty array if none. + /// + /// If there's no such object definition. + /// + IList GetAliases(string name); #if !MONO /// diff --git a/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs b/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs index c94455d9..eee5e85b 100644 --- a/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs +++ b/src/Spring/Spring.Core/Objects/Factory/ObjectFactoryUtils.cs @@ -111,7 +111,7 @@ namespace Spring.Objects.Factory /// public static int CountObjectsIncludingAncestors(IListableObjectFactory factory) { - return ObjectNamesIncludingAncestors(factory).Length; + return ObjectNamesIncludingAncestors(factory).Count; } /// @@ -119,7 +119,7 @@ namespace Spring.Objects.Factory /// /// The object factory. /// The array of object names, or an empty array if none. - public static string[] ObjectNamesIncludingAncestors(IListableObjectFactory factory) + public static IList ObjectNamesIncludingAncestors(IListableObjectFactory factory) { return ObjectNamesForTypeIncludingAncestors(factory, typeof(object)); } @@ -159,7 +159,7 @@ namespace Spring.Objects.Factory /// /// The array of object names, or an empty array if none. /// - public static string[] ObjectNamesForTypeIncludingAncestors( + public static IList ObjectNamesForTypeIncludingAncestors( IListableObjectFactory factory, Type type, bool includePrototypes, bool includeFactoryObjects) { @@ -169,7 +169,7 @@ namespace Spring.Objects.Factory if (pof != null) { IHierarchicalObjectFactory hof = (IHierarchicalObjectFactory)factory; - string[] parentsResult = ObjectNamesForTypeIncludingAncestors(pof, type, includePrototypes, includeFactoryObjects); + IList parentsResult = ObjectNamesForTypeIncludingAncestors(pof, type, includePrototypes, includeFactoryObjects); foreach (string objectName in parentsResult) { if (!result.Contains(objectName) && !hof.ContainsLocalObject(objectName)) @@ -178,7 +178,7 @@ namespace Spring.Objects.Factory } } } - return result.ToArray(); + return result; } /// @@ -209,7 +209,7 @@ namespace Spring.Objects.Factory /// /// The array of object names, or an empty array if none. /// - public static string[] ObjectNamesForTypeIncludingAncestors( + public static IList ObjectNamesForTypeIncludingAncestors( IListableObjectFactory factory, Type type) { List result = new List(); @@ -218,7 +218,7 @@ namespace Spring.Objects.Factory if (pof != null) { IHierarchicalObjectFactory hof = (IHierarchicalObjectFactory)factory; - string[] parentsResult = ObjectNamesForTypeIncludingAncestors(pof, type); + IList parentsResult = ObjectNamesForTypeIncludingAncestors(pof, type); foreach (string objectName in parentsResult) { if (!result.Contains(objectName) && !hof.ContainsLocalObject(objectName)) @@ -227,7 +227,7 @@ namespace Spring.Objects.Factory } } } - return result.ToArray(); + return result; } /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs index 25803c29..e7af9d00 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs @@ -349,15 +349,15 @@ namespace Spring.Objects.Factory.Support /// protected void ApplyPropertyValues(string name, RootObjectDefinition definition, IObjectWrapper wrapper, IPropertyValues properties) { - if (properties == null || properties.PropertyValues.Length == 0) + if (properties == null || properties.PropertyValues.Count == 0) { return; } ObjectDefinitionValueResolver valueResolver = CreateValueResolver(); MutablePropertyValues deepCopy = new MutablePropertyValues(properties); - PropertyValue[] copiedProperties = deepCopy.PropertyValues; - for (int i = 0; i < copiedProperties.Length; ++i) + IList copiedProperties = deepCopy.PropertyValues; + for (int i = 0; i < copiedProperties.Count; ++i) { PropertyValue copiedProperty = copiedProperties[i]; //(string name, RootObjectDefinition definition, string argumentName, object argumentValue) @@ -500,7 +500,7 @@ namespace Spring.Objects.Factory.Support if (wrapper == null) { - if (properties.PropertyValues.Length > 0) + if (properties.PropertyValues.Count > 0) { throw new ObjectCreationException(definition.ResourceDescription, name, "Cannot apply property values to null instance."); @@ -534,7 +534,7 @@ namespace Spring.Objects.Factory.Support if (hasInstAwareOpps || needsDepCheck) { - PropertyInfo[] filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); + IList filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); if (hasInstAwareOpps) { foreach (IObjectPostProcessor processor in ObjectPostProcessors) @@ -834,7 +834,7 @@ namespace Spring.Objects.Factory.Support protected internal override object InstantiateObject(string name, RootObjectDefinition definition, object[] arguments, bool allowEagerCaching, bool suppressConfigure) { // guarantee the initialization of objects that the current one depends on.. - if (definition.DependsOn != null && definition.DependsOn.Length > 0) + if (definition.DependsOn != null && definition.DependsOn.Count > 0) { foreach (string dependant in definition.DependsOn) { @@ -1155,7 +1155,7 @@ namespace Spring.Objects.Factory.Support return; } - PropertyInfo[] filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); + IList filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); if (HasInstantiationAwareBeanPostProcessors) { foreach (IObjectPostProcessor processor in ObjectPostProcessors) @@ -1177,12 +1177,12 @@ namespace Spring.Objects.Factory.Support CheckDependencies(name, definition, filteredPropInfo, properties); } - private void CheckDependencies(string name, IConfigurableObjectDefinition definition, PropertyInfo[] filteredPropInfo, IPropertyValues properties) + private void CheckDependencies(string name, IConfigurableObjectDefinition definition, IList filteredPropInfo, IPropertyValues properties) { DependencyCheckingMode dependencyCheck = definition.DependencyCheck; - PropertyInfo[] unsatisfiedDependencies = AutowireUtils.GetUnsatisfiedDependencies(filteredPropInfo, properties, dependencyCheck); + IList unsatisfiedDependencies = AutowireUtils.GetUnsatisfiedDependencies(filteredPropInfo, properties, dependencyCheck); - if (unsatisfiedDependencies.Length > 0) + if (unsatisfiedDependencies.Count > 0) { throw new UnsatisfiedDependencyException(definition.ResourceDescription, name, unsatisfiedDependencies[0].Name, "Set this property value or disable dependency checking for this object."); @@ -1195,11 +1195,11 @@ namespace Spring.Objects.Factory.Support /// /// The object wrapper the object was created with. /// The filtered PropertyInfos - private PropertyInfo[] FilterPropertyInfoForDependencyCheck(IObjectWrapper wrapper) + private IList FilterPropertyInfoForDependencyCheck(IObjectWrapper wrapper) { lock (filteredPropertyDescriptorsCache) { - PropertyInfo[] filtered; + IList filtered; if (!filteredPropertyDescriptorsCache.TryGetValue(wrapper.WrappedType, out filtered)) { @@ -1213,7 +1213,7 @@ namespace Spring.Objects.Factory.Support } } - filtered = list.ToArray(); + filtered = list; filteredPropertyDescriptorsCache.Add(wrapper.WrappedType, filtered); } return filtered; @@ -1461,7 +1461,7 @@ namespace Spring.Objects.Factory.Support /// private void DestroyDependantObjects(string name) { - string[] dependingObjects = GetDependingObjectNames(name); + IList dependingObjects = GetDependingObjectNames(name); foreach (string doName in dependingObjects) { DestroySingleton(doName); @@ -1769,7 +1769,7 @@ namespace Spring.Objects.Factory.Support /// /// In case of errors. /// - protected abstract string[] GetDependingObjectNames(string name); + protected abstract IList GetDependingObjectNames(string name); /// /// Injects dependencies into the supplied instance @@ -2080,7 +2080,7 @@ namespace Spring.Objects.Factory.Support /// /// Cache of filtered PropertyInfos: object Type -> PropertyInfo array /// - private IDictionary filteredPropertyDescriptorsCache = new Dictionary(); + 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 6defe1cd..e12ba0ae 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs @@ -21,12 +21,11 @@ #region Imports using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Text; -using Spring.Core; + using Spring.Core.TypeResolution; using Spring.Objects.Factory.Config; using Spring.Util; @@ -135,9 +134,8 @@ namespace Spring.Objects.Factory.Support InitMethodName = other.InitMethodName; DestroyMethodName = other.DestroyMethodName; - DependsOn = new string[other.DependsOn.Length]; IsAutowireCandidate = other.IsAutowireCandidate; - Array.Copy(other.DependsOn, DependsOn, other.DependsOn.Length); + DependsOn = new List(other.DependsOn); FactoryMethodName = other.FactoryMethodName; FactoryObjectName = other.FactoryObjectName; AutowireMode = other.AutowireMode; @@ -524,10 +522,10 @@ namespace Spring.Objects.Factory.Support /// preparation on startup. /// /// - public string[] DependsOn + public IList DependsOn { get { return dependsOn; } - set { dependsOn = value == null ? StringUtils.EmptyStrings : value; } + set { dependsOn = value ?? StringUtils.EmptyStrings; } } /// @@ -739,14 +737,14 @@ namespace Spring.Objects.Factory.Support { FactoryMethodName = other.FactoryMethodName; } - if (ArrayUtils.HasLength(other.DependsOn)) + if (other.DependsOn != null && other.DependsOn.Count > 0) { List deps = new List(other.DependsOn); - if (ArrayUtils.HasLength(DependsOn)) + if (DependsOn != null && DependsOn.Count > 0) { deps.AddRange(DependsOn); } - DependsOn = deps.ToArray(); + DependsOn = deps; } AutowireMode = other.AutowireMode; ResourceDescription = other.ResourceDescription; @@ -811,7 +809,7 @@ namespace Spring.Objects.Factory.Support private object objectType; private AutoWiringMode autowireMode = AutoWiringMode.No; private DependencyCheckingMode dependencyCheck = DependencyCheckingMode.None; - private string[] dependsOn; + private IList dependsOn; private bool autowireCandidate = true; private string initMethodName = null; private string destroyMethodName = null; diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs index 7cd5c38b..446336bd 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs @@ -29,7 +29,6 @@ using System.ComponentModel; using Common.Logging; using Spring.Collections; -using Spring.Collections.Generic; using Spring.Core; using Spring.Core.TypeConversion; using Spring.Objects.Factory.Config; @@ -1211,7 +1210,7 @@ namespace Spring.Objects.Factory.Support /// The names of objects in the singleton cache that match the given /// object type (including subclasses), or an empty array if none. /// - public virtual string[] GetSingletonNames(Type type) + public virtual IList GetSingletonNames(Type type) { lock (singletonCache) { @@ -1225,7 +1224,7 @@ namespace Spring.Objects.Factory.Support matches.Add(name); } } - return matches.ToArray(); + return matches; } } @@ -1448,12 +1447,12 @@ namespace Spring.Objects.Factory.Support ///

/// /// The names of the objects in the singleton cache. - public virtual string[] GetSingletonNames() + public virtual IList GetSingletonNames() { lock (singletonCache) { IEnumerable keys = singletonCache.Keys.Cast(); - return new List(keys).ToArray(); + return new List(keys); } } @@ -1622,7 +1621,7 @@ namespace Spring.Objects.Factory.Support /// /// Set of registered singletons, containing the bean names in registration order /// - private ISet registeredSingletons = new HashedSet(); + private HashSet registeredSingletons = new HashSet(); private readonly IDictionary singletonsInCreation; @@ -1815,7 +1814,7 @@ namespace Spring.Objects.Factory.Support /// Return the aliases for the given object name, if defined. ///
/// . - public string[] GetAliases(string name) + public IList GetAliases(string name) { string objectName = TransformedObjectName(name); // check if object actually exists in this object factory... @@ -1834,7 +1833,7 @@ namespace Spring.Objects.Factory.Support } } } - return matches.ToArray(); + return matches; } // not found, so check parent... @@ -2534,7 +2533,7 @@ namespace Spring.Objects.Factory.Support /// /// /// - public string[] SingletonNames + public IList SingletonNames { get { diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs index 9f8d4634..b68e6747 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AutowireUtils.cs @@ -24,10 +24,10 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; + using Spring.Collections; using Spring.Core; using Spring.Objects.Factory.Config; -using Spring.Objects.Support; using Spring.Util; #endregion @@ -355,7 +355,7 @@ namespace Spring.Objects.Factory.Support /// Returns the list of that are not satisfied by . ///
/// the filtered list. Is never null - public static PropertyInfo[] GetUnsatisfiedDependencies(PropertyInfo[] propertyInfos, IPropertyValues properties, DependencyCheckingMode dependencyCheck) + public static IList GetUnsatisfiedDependencies(IList propertyInfos, IPropertyValues properties, DependencyCheckingMode dependencyCheck) { List unsatisfiedDependenciesList = new List(); foreach (PropertyInfo property in propertyInfos) @@ -371,7 +371,7 @@ namespace Spring.Objects.Factory.Support } } } - return unsatisfiedDependenciesList.ToArray(); + return unsatisfiedDependenciesList; } } } \ 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 c862ce91..979f966e 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ConstructorResolver.cs @@ -31,6 +31,8 @@ using Spring.Core.TypeResolution; using Spring.Objects.Factory.Config; using Spring.Util; +using System.Linq; + namespace Spring.Objects.Factory.Support { /// @@ -307,12 +309,12 @@ namespace Spring.Objects.Factory.Support } GenericArgumentsHolder genericArgsInfo = new GenericArgumentsHolder(definition.FactoryMethodName); - MethodInfo[] factoryMethodCandidates = FindMethods(genericArgsInfo.GenericMethodName, expectedArgCount, isStatic, factoryClass); + IList factoryMethodCandidates = FindMethods(genericArgsInfo.GenericMethodName, expectedArgCount, isStatic, factoryClass); bool autowiring = (definition.AutowireMode == AutoWiringMode.Constructor); // try all matching methods to see if they match the constructor arguments... - for (int i = 0; i < factoryMethodCandidates.Length; i++) + for (int i = 0; i < factoryMethodCandidates.Count; i++) { MethodInfo factoryMethodCandidate = factoryMethodCandidates[i]; if (genericArgsInfo.ContainsGenericArguments) @@ -610,16 +612,14 @@ namespace Spring.Objects.Factory.Support /// methods exposed on the /// that match the supplied criteria. /// - private static MethodInfo[] FindMethods(string methodName, int expectedArgumentCount, bool isStatic, Type searchType) + private static IList FindMethods(string methodName, int expectedArgumentCount, bool isStatic, Type searchType) { ComposedCriteria methodCriteria = new ComposedCriteria(); methodCriteria.Add(new MethodNameMatchCriteria(methodName)); methodCriteria.Add(new MethodParametersCountCriteria(expectedArgumentCount)); BindingFlags methodFlags = BindingFlags.Public | BindingFlags.IgnoreCase | (isStatic ? BindingFlags.Static : BindingFlags.Instance); - MemberInfo[] methods = - searchType.FindMembers(MemberTypes.Method, methodFlags, new MemberFilter(new CriteriaMemberFilter().FilterMemberByCriteria), - methodCriteria); - return (MethodInfo[])ArrayList.Adapter(methods).ToArray(typeof(MethodInfo)); + MemberInfo[] methods = searchType.FindMembers(MemberTypes.Method, methodFlags, new CriteriaMemberFilter().FilterMemberByCriteria, methodCriteria); + return methods.Cast().ToArray(); } internal class ArgumentsHolder { diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs index b30915d7..8092101f 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs @@ -217,16 +217,15 @@ namespace Spring.Objects.Factory.Support /// /// In case of errors. /// - protected override string[] GetDependingObjectNames(string objectName) + protected override IList GetDependingObjectNames(string objectName) { List dependingObjectNames = new List(); - string[] allObjectDefinitionNames = GetObjectDefinitionNames(); + IList allObjectDefinitionNames = GetObjectDefinitionNames(); foreach (string name in allObjectDefinitionNames) { if (ContainsObjectDefinition(name)) { - RootObjectDefinition rod - = GetMergedObjectDefinition(name, false); + RootObjectDefinition rod = GetMergedObjectDefinition(name, false); if (rod.DependsOn != null) { HashSet dependsOn = new HashSet(rod.DependsOn); @@ -249,7 +248,7 @@ namespace Spring.Objects.Factory.Support } } } - return dependingObjectNames.ToArray(); + return dependingObjectNames; } /// @@ -604,9 +603,9 @@ namespace Spring.Objects.Factory.Support /// are defined. /// /// - public string[] GetObjectDefinitionNames() + public IList GetObjectDefinitionNames() { - return objectDefinitionNames.ToArray(); + return objectDefinitionNames; } /// @@ -622,7 +621,7 @@ namespace Spring.Objects.Factory.Support /// are defined. /// /// - public string[] GetObjectDefinitionNames(Type type) + public IList GetObjectDefinitionNames(Type type) { List matches = new List(); foreach (string name in objectDefinitionNames) @@ -632,7 +631,7 @@ namespace Spring.Objects.Factory.Support matches.Add(name); } } - return matches.ToArray(); + return matches; } /// @@ -648,7 +647,7 @@ namespace Spring.Objects.Factory.Support /// are defined. /// /// - public string[] GetObjectNamesForType(Type type) + public IList GetObjectNamesForType(Type type) { return GetObjectNamesForType(type, true, true); } @@ -676,7 +675,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType() + public IList GetObjectNames() { return GetObjectNamesForType(typeof (T)); } @@ -702,10 +701,10 @@ namespace Spring.Objects.Factory.Support /// are defined. /// /// - public string[] GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects) { List objectNames = DoGetObjectNamesForType(type, includePrototypes, includeFactoryObjects); - return objectNames.ToArray(); + return objectNames; } /// @@ -743,7 +742,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType(bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNames(bool includePrototypes, bool includeFactoryObjects) { return GetObjectNamesForType(typeof (T), includePrototypes, includeFactoryObjects); } @@ -799,7 +798,7 @@ namespace Spring.Objects.Factory.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType() + public IDictionary GetObjects() { Dictionary result = new Dictionary(); DoGetObjectsOfType(typeof (T), true, true, result); @@ -896,7 +895,7 @@ namespace Spring.Objects.Factory.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects) + public IDictionary GetObjects(bool includePrototypes, bool includeFactoryObjects) { Dictionary result = new Dictionary(); DoGetObjectsOfType(typeof (T), includePrototypes, includeFactoryObjects, result); @@ -934,13 +933,13 @@ namespace Spring.Objects.Factory.Support /// public T GetObject() { - string[] objectNamesForType = GetObjectNamesForType(typeof(T)); - if ((objectNamesForType == null) || (objectNamesForType.Length == 0)) + IList objectNamesForType = GetObjectNamesForType(typeof(T)); + if ((objectNamesForType == null) || (objectNamesForType.Count == 0)) { throw new NoSuchObjectDefinitionException(typeof(T).FullName, "Requested Type not Defined in the Context."); } - if (objectNamesForType.Length > 1) + if (objectNamesForType.Count > 1) { throw new ObjectDefinitionStoreException(string.Format("More than one definition for {0} found in the Context.", typeof(T).FullName)); } @@ -975,7 +974,7 @@ namespace Spring.Objects.Factory.Support protected List DoGetObjectNamesForType(Type type, bool includeNonSingletons, bool allowEagerInit) { List result = new List(); - string[] objectNames = GetObjectDefinitionNames(); + IList objectNames = GetObjectDefinitionNames(); foreach (string s in objectNames) { string objectName = s; @@ -1033,7 +1032,7 @@ namespace Spring.Objects.Factory.Support } // check singletons too, to catch manually registered singletons... - string[] singletonNames = GetSingletonNames(); + IList singletonNames = GetSingletonNames(); foreach (string s in singletonNames) { string objectName = s; @@ -1170,9 +1169,9 @@ namespace Spring.Objects.Factory.Support private IDictionary FindAutowireCandidates(string objectName, Type requiredType, DependencyDescriptor descriptor) { - string[] candidateNames = + IList candidateNames = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(this, requiredType, true, descriptor.Eager); - IDictionary result = new OrderedDictionary(candidateNames.Length); + IDictionary result = new OrderedDictionary(candidateNames.Count); foreach (DictionaryEntry entry in resolvableDependencies) { @@ -1187,7 +1186,7 @@ namespace Spring.Objects.Factory.Support } } } - for (int i = 0; i < candidateNames.Length; i++) + for (int i = 0; i < candidateNames.Count; i++) { string candidateName = candidateNames[i]; if (!candidateName.Equals(objectName) && IsAutowireCandidate(candidateName, descriptor)) diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/IConfigurableObjectDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Support/IConfigurableObjectDefinition.cs index 008684c2..35429241 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/IConfigurableObjectDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/IConfigurableObjectDefinition.cs @@ -21,6 +21,8 @@ #region Imports using System; +using System.Collections.Generic; + using Spring.Objects.Factory.Config; #endregion @@ -159,7 +161,7 @@ namespace Spring.Objects.Factory.Support /// preparation on startup. ///

/// - new string[] DependsOn { get; set; } + new IList DependsOn { get; set; } /// /// The name of the initializer method. diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistry.cs b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistry.cs index e80a6de7..25ca92cc 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistry.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistry.cs @@ -20,6 +20,8 @@ #region Imports +using System.Collections.Generic; + using Spring.Objects.Factory; using Spring.Objects.Factory.Config; @@ -69,7 +71,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this registry, or an empty array /// if none defined /// - string [] GetObjectDefinitionNames (); + IList GetObjectDefinitionNames (); /// /// Check if this registry contains a object definition with the given name. @@ -126,25 +128,25 @@ namespace Spring.Objects.Factory.Support /// If the object definition is invalid. /// void RegisterObjectDefinition (string name, IObjectDefinition definition); - - /// - /// Return the aliases for the given object name, if defined. - /// - /// the object name to check for aliases - /// - /// - ///

- /// Will ask the parent factory if the object cannot be found in this - /// factory instance. - ///

- ///
- /// - /// The aliases, or an empty array if none. - /// - /// - /// If there's no such object definition. - /// - string [] GetAliases (string name); + + /// + /// Return the aliases for the given object name, if defined. + /// + /// the object name to check for aliases + /// + /// + ///

+ /// Will ask the parent factory if the object cannot be found in this + /// factory instance. + ///

+ ///
+ /// + /// The aliases, or an empty array if none. + /// + /// + /// If there's no such object definition. + /// + IList GetAliases (string name); /// /// Given a object name, create an alias. We typically use this method to diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs index e3a9a068..49e80bae 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs @@ -397,7 +397,7 @@ namespace Spring.Objects.Factory.Support List arrayList = new List(); arrayList.AddRange(objectDefinition.DependsOn); arrayList.AddRange(new string[]{ objectName}); - objectDefinition.DependsOn = arrayList.ToArray(); + objectDefinition.DependsOn = arrayList; } return this; } diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionReaderUtils.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionReaderUtils.cs index 878cb901..613e33b4 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionReaderUtils.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionReaderUtils.cs @@ -21,9 +21,9 @@ #region Imports using System; -using System.Text; +using System.Collections.Generic; using System.Text.RegularExpressions; -using Spring.Objects.Factory; + using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Xml; using Spring.Objects.Support; @@ -96,8 +96,8 @@ namespace Spring.Objects.Factory.Support AssertUtils.ArgumentNotNull(registry, "registry"); registry.RegisterObjectDefinition(objectDefinition.ObjectName, objectDefinition.ObjectDefinition); - string[] aliases = objectDefinition.Aliases; - for (int i = 0; i < aliases.Length; ++i) + IList aliases = objectDefinition.Aliases; + for (int i = 0; i < aliases.Count; ++i) { string alias = aliases[i]; registry.RegisterAlias(objectDefinition.ObjectName, alias); diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs index 03244397..445fbd52 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/StaticListableObjectFactory.cs @@ -498,7 +498,7 @@ namespace Spring.Objects.Factory.Support /// /// If there's no such object definition. /// - public string[] GetAliases(string name) + public IList GetAliases(string name) { return StringUtils.EmptyStrings; } @@ -551,10 +551,10 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectDefinitionNames() + public IList GetObjectDefinitionNames() { List names = new List(objects.Keys); - return names.ToArray(); + return names; } /// @@ -575,7 +575,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectDefinitionNames(Type type) + public IList GetObjectDefinitionNames(Type type) { List matches = new List(); foreach (string name in objects.Keys) @@ -586,7 +586,7 @@ namespace Spring.Objects.Factory.Support matches.Add(name); } } - return matches.ToArray(); + return matches; } /// @@ -612,7 +612,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType(Type type) + public IList GetObjectNamesForType(Type type) { return GetObjectNamesForType(type, true, true); } @@ -640,7 +640,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType() + public IList GetObjectNames() { return GetObjectNamesForType(typeof(T)); } @@ -674,8 +674,7 @@ namespace Spring.Objects.Factory.Support /// are defined. /// /// - public string[] GetObjectNamesForType( - Type type, bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects) { bool isFactoryType = (type != null && typeof(IFactoryObject).IsAssignableFrom(type)); List matches = new List(); @@ -701,7 +700,7 @@ namespace Spring.Objects.Factory.Support } } } - return matches.ToArray(); + return matches; } /// @@ -739,7 +738,7 @@ namespace Spring.Objects.Factory.Support /// The names of all objects defined in this factory, or an empty array if none /// are defined. /// - public string[] GetObjectNamesForType(bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNames(bool includePrototypes, bool includeFactoryObjects) { return GetObjectNamesForType(typeof(T), includePrototypes, includeFactoryObjects); } @@ -816,7 +815,7 @@ namespace Spring.Objects.Factory.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType() + public IDictionary GetObjects() { Dictionary collector = new Dictionary(); DoGetObjectsOfType(typeof(T), true, true, collector); @@ -917,7 +916,7 @@ namespace Spring.Objects.Factory.Support /// /// If the objects could not be created. /// - public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects) + public IDictionary GetObjects(bool includePrototypes, bool includeFactoryObjects) { Dictionary collector = new Dictionary(); DoGetObjectsOfType(typeof(T), includeFactoryObjects, includePrototypes, collector); @@ -955,13 +954,13 @@ namespace Spring.Objects.Factory.Support /// public T GetObject() { - string[] objectNamesForType = GetObjectNamesForType(typeof(T)); - if ((objectNamesForType == null) || (objectNamesForType.Length == 0)) + IList objectNamesForType = GetObjectNamesForType(typeof(T)); + if ((objectNamesForType == null) || (objectNamesForType.Count == 0)) { throw new NoSuchObjectDefinitionException(typeof(T).FullName, "Requested Type not Defined in the Context."); } - if (objectNamesForType.Length > 1) + if (objectNamesForType.Count > 1) { throw new ObjectDefinitionStoreException(string.Format("More than one definition for {0} found in the Context.", typeof(T).FullName)); } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs index b8fb31bc..d4a64c38 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs @@ -322,8 +322,8 @@ namespace Spring.Objects.Factory.Xml #endregion } - string[] aliasesArray = aliases.ToArray(); - return CreateObjectDefinitionHolder(element, definition, objectName, aliasesArray); + + return CreateObjectDefinitionHolder(element, definition, objectName, aliases); } return null; } @@ -334,9 +334,9 @@ namespace Spring.Objects.Factory.Xml /// /// This method may be used as a last resort to post-process an object definition before it gets added to the registry. /// - protected virtual ObjectDefinitionHolder CreateObjectDefinitionHolder(XmlElement element, IConfigurableObjectDefinition definition, string objectName, string[] aliasesArray) + protected virtual ObjectDefinitionHolder CreateObjectDefinitionHolder(XmlElement element, IConfigurableObjectDefinition definition, string objectName, IList aliases) { - return new ObjectDefinitionHolder(definition, objectName, aliasesArray); + return new ObjectDefinitionHolder(definition, objectName, aliases); } /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs index f4644ebd..4f2a34a8 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs @@ -26,13 +26,11 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.IO; -using System.Text; using System.Xml; -using System.Xml.Schema; + using Common.Logging; using Spring.Collections; -using Spring.Core; using Spring.Core.IO; using Spring.Core.TypeResolution; using Spring.Objects.Factory.Config; diff --git a/src/Spring/Spring.Core/Objects/IPropertyValues.cs b/src/Spring/Spring.Core/Objects/IPropertyValues.cs index 34416d06..f9876ac3 100644 --- a/src/Spring/Spring.Core/Objects/IPropertyValues.cs +++ b/src/Spring/Spring.Core/Objects/IPropertyValues.cs @@ -21,6 +21,7 @@ #region Imports using System.Collections; +using System.Collections.Generic; #endregion @@ -41,7 +42,7 @@ namespace Spring.Objects /// An array of the objects held /// in this object. /// - PropertyValue [] PropertyValues + IList PropertyValues { get; } diff --git a/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs b/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs index e8833b7d..4583bd74 100644 --- a/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs +++ b/src/Spring/Spring.Core/Objects/MutablePropertyValues.cs @@ -70,8 +70,8 @@ namespace Spring.Objects /// s can be added with the various /// overloaded , /// , - /// , - /// and + /// , + /// and /// methods. ///

/// @@ -96,7 +96,7 @@ namespace Spring.Objects { if (other != null) { - AddAll (other.PropertyValues); + AddAll(other.PropertyValues); } } @@ -108,7 +108,7 @@ namespace Spring.Objects /// The with property values /// keyed by property name, which must be a . /// - public MutablePropertyValues (IDictionary map) + public MutablePropertyValues (IDictionary map) { AddAll (map); } @@ -120,9 +120,9 @@ namespace Spring.Objects /// /// Property to retrieve the array of property values. /// - public PropertyValue[] PropertyValues + public IList PropertyValues { - get { return propertyValuesList.ToArray(); } + get { return propertyValuesList; } } #endregion @@ -154,7 +154,7 @@ namespace Spring.Objects { for (int i = 0; i < propertyValuesList.Count; ++i) { - PropertyValue currentPv = (PropertyValue) propertyValuesList [i]; + PropertyValue currentPv = propertyValuesList [i]; if (currentPv.Name.Equals (pv.Name)) { pv = MergeIfRequired(pv, currentPv); @@ -196,13 +196,13 @@ namespace Spring.Objects /// The map of property values, the keys of which must be /// s. /// - public void AddAll (IDictionary map) + public void AddAll (IDictionary map) { if (map != null) { - foreach (string key in map.Keys) + foreach (KeyValuePair pair in map) { - Add (new PropertyValue (key, map [key])); + Add (new PropertyValue (pair.Key, pair.Value)); } } } @@ -214,7 +214,7 @@ namespace Spring.Objects /// /// The list of s to be added. /// - public void AddAll (IList values) + public void AddAll(IList values) { if (values != null) { @@ -357,10 +357,10 @@ namespace Spring.Objects /// public override string ToString () { - PropertyValue[] pvs = PropertyValues; + IList pvs = PropertyValues; StringBuilder sb = new StringBuilder ( - "MutablePropertyValues: length=").Append (pvs.Length).Append ("; "); + "MutablePropertyValues: length=").Append (pvs.Count).Append ("; "); sb.Append (StringUtils.ArrayToDelimitedString (pvs, ",")); return sb.ToString (); } diff --git a/src/Spring/Spring.Core/Objects/PropertyAccessExceptionsException.cs b/src/Spring/Spring.Core/Objects/PropertyAccessExceptionsException.cs index 817e6d28..3a167f59 100644 --- a/src/Spring/Spring.Core/Objects/PropertyAccessExceptionsException.cs +++ b/src/Spring/Spring.Core/Objects/PropertyAccessExceptionsException.cs @@ -102,10 +102,7 @@ namespace Spring.Objects : base(string.Empty) { _objectWrapper = objectWrapper; - _propertyAccessExceptions - = propertyAccessExceptions == null ? - EmptyPropertyAccessExceptions : - propertyAccessExceptions; + _propertyAccessExceptions = propertyAccessExceptions ?? EmptyPropertyAccessExceptions; } /// diff --git a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs index 93f8b50d..ea861e29 100644 --- a/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs +++ b/src/Spring/Spring.Core/Proxy/AbstractProxyTypeBuilder.cs @@ -62,7 +62,7 @@ namespace Spring.Proxy private string _name; private Type _targetType; private Type _baseType = typeof (object); - private Type[] _interfaces; + private IList _interfaces; private bool _proxyTargetAttributes = true; private IList _typeAttributes = new ArrayList(); private IDictionary _memberAttributes = new Hashtable(); @@ -126,7 +126,7 @@ namespace Spring.Proxy /// The default value of this property is all the interfaces /// implemented or inherited by the target type. /// - public Type[] Interfaces + public IList Interfaces { get { @@ -873,22 +873,22 @@ namespace Spring.Proxy #endregion - /// - /// Returns an array of s that represent - /// the proxiable interfaces. - /// - /// - /// An interface is proxiable if it's not marked with the - /// . - /// - /// - /// The array of interfaces from which - /// we want to get the proxiable interfaces. - /// - /// - /// An array containing the interface s. - /// - protected virtual Type[] GetProxiableInterfaces(Type[] interfaces) + /// + /// Returns an array of s that represent + /// the proxiable interfaces. + /// + /// + /// An interface is proxiable if it's not marked with the + /// . + /// + /// + /// The array of interfaces from which + /// we want to get the proxiable interfaces. + /// + /// + /// An array containing the interface s. + /// + protected virtual IList GetProxiableInterfaces(IList interfaces) { List proxiableInterfaces = new List(); @@ -914,7 +914,7 @@ namespace Spring.Proxy } } - return proxiableInterfaces.ToArray(); + return proxiableInterfaces; } /// diff --git a/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs index 9a0059ff..8e9ad773 100644 --- a/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs +++ b/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs @@ -102,7 +102,7 @@ namespace Spring.Proxy /// public override Type BuildProxyType() { - if (Interfaces == null || Interfaces.Length == 0) + if (Interfaces == null || Interfaces.Count == 0) { throw new ArgumentException( "Composition proxy target must implement at least one interface."); diff --git a/src/Spring/Spring.Core/Proxy/IProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/IProxyTypeBuilder.cs index f2cf8e2b..a88e8e6e 100644 --- a/src/Spring/Spring.Core/Proxy/IProxyTypeBuilder.cs +++ b/src/Spring/Spring.Core/Proxy/IProxyTypeBuilder.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; #endregion @@ -60,7 +61,7 @@ namespace Spring.Proxy /// /// Gets or sets the list of interfaces proxy should implement. /// - Type[] Interfaces { get; set; } + IList Interfaces { get; set; } /// /// Should we proxy target attributes? diff --git a/src/Spring/Spring.Core/Util/EventUtils.cs b/src/Spring/Spring.Core/Util/EventUtils.cs index a3a71d6c..6d897724 100644 --- a/src/Spring/Spring.Core/Util/EventUtils.cs +++ b/src/Spring/Spring.Core/Util/EventUtils.cs @@ -47,14 +47,14 @@ namespace Spring.Util get { return _eventExceptions.Count > 0; } } - public Delegate[] Sources + public IList Sources { - get { return new List(_eventExceptions.Keys).ToArray(); } + get { return new List(_eventExceptions.Keys); } } - public Exception[] Exceptions + public IList Exceptions { - get { return new List(_eventExceptions.Values).ToArray(); } + get { return new List(_eventExceptions.Values); } } public Exception this[Delegate source] diff --git a/src/Spring/Spring.Core/Util/IEventExceptionsCollector.cs b/src/Spring/Spring.Core/Util/IEventExceptionsCollector.cs index bf6cc365..710f1cf6 100644 --- a/src/Spring/Spring.Core/Util/IEventExceptionsCollector.cs +++ b/src/Spring/Spring.Core/Util/IEventExceptionsCollector.cs @@ -1,12 +1,13 @@ using System; +using System.Collections.Generic; namespace Spring.Util { public interface IEventExceptionsCollector { bool HasExceptions { get; } - Delegate[] Sources { get;} - Exception[] Exceptions { get; } + IList Sources { get;} + IList Exceptions { get; } Exception this[Delegate source] { get; } } } \ No newline at end of file diff --git a/src/Spring/Spring.Core/Util/ReflectionUtils.cs b/src/Spring/Spring.Core/Util/ReflectionUtils.cs index 625b59a3..a10f64bd 100644 --- a/src/Spring/Spring.Core/Util/ReflectionUtils.cs +++ b/src/Spring/Spring.Core/Util/ReflectionUtils.cs @@ -386,7 +386,7 @@ namespace Spring.Util /// /// If more than 1 matching methods are found in the list. /// - public static MethodInfo GetMethodByArgumentValues(MethodInfo[] methods, object[] argValues) + public static MethodInfo GetMethodByArgumentValues(IEnumerable methods, object[] argValues) where T : MethodBase { return (MethodInfo)GetMethodBaseByArgumentValues("method", methods, argValues); } @@ -401,8 +401,7 @@ namespace Spring.Util /// /// If more than 1 matching methods are found in the list. /// - private static MethodBase GetMethodBaseByArgumentValues(string methodTypeName, MethodBase[] methods, - object[] argValues) + private static MethodBase GetMethodBaseByArgumentValues(string methodTypeName, IEnumerable methods, object[] argValues) where T : MethodBase { MethodBase match = null; int matchCount = 0; @@ -490,7 +489,7 @@ namespace Spring.Util /// /// If more than 1 matching methods are found in the list. /// - public static ConstructorInfo GetConstructorByArgumentValues(ConstructorInfo[] methods, object[] argValues) + public static ConstructorInfo GetConstructorByArgumentValues(IList methods, object[] argValues) where T : MethodBase { return (ConstructorInfo)GetMethodBaseByArgumentValues("constructor", methods, argValues); } @@ -540,7 +539,7 @@ namespace Spring.Util /// /// If is . /// - public static Type[] ToInterfaceArray(Type intf) + public static IList ToInterfaceArray(Type intf) { AssertUtils.ArgumentNotNull(intf, "intf"); @@ -555,7 +554,7 @@ namespace Spring.Util List interfaces = new List(intf.GetInterfaces()); interfaces.Add(intf); - return interfaces.ToArray(); + return interfaces; } /// diff --git a/src/Spring/Spring.Core/Util/StringUtils.cs b/src/Spring/Spring.Core/Util/StringUtils.cs index a0791ec4..a37c72a9 100644 --- a/src/Spring/Spring.Core/Util/StringUtils.cs +++ b/src/Spring/Spring.Core/Util/StringUtils.cs @@ -325,8 +325,8 @@ namespace Spring.Util /// The delimiter to use (probably a ','). /// /// The delimited string representation. - public static string CollectionToDelimitedString( - ICollection c, string delimiter) + public static string CollectionToDelimitedString( + IEnumerable c, string delimiter) { if (c == null) { @@ -354,8 +354,7 @@ namespace Spring.Util /// The to display. /// /// The delimited string representation. - public static string CollectionToCommaDelimitedString( - ICollection collection) + public static string CollectionToCommaDelimitedString(IEnumerable collection) { return CollectionToDelimitedString(collection, ","); } @@ -369,7 +368,7 @@ namespace Spring.Util /// will be called on each /// element). /// - public static string ArrayToCommaDelimitedString(object[] source) + public static string ArrayToCommaDelimitedString(IEnumerable source) { return ArrayToDelimitedString(source, ","); } @@ -386,8 +385,7 @@ namespace Spring.Util /// /// The delimiter to use (probably a ','). /// - public static string ArrayToDelimitedString( - object[] source, string delimiter) + public static string ArrayToDelimitedString(IEnumerable source, string delimiter) { if (source == null) { diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs index 209a8a95..21c44914 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ObjectsFactory.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using NHibernate.Bytecode; @@ -53,8 +54,8 @@ namespace Spring.Data.NHibernate.Bytecode /// A reference to the created object. public object CreateInstance(Type type) { - string[] namesForType = listableObjectFactory.GetObjectNamesForType(type); - return namesForType.Length > 0 ? listableObjectFactory.GetObject(namesForType[0], type) : Activator.CreateInstance(type); + IList namesForType = listableObjectFactory.GetObjectNamesForType(type); + return namesForType.Count > 0 ? listableObjectFactory.GetObject(namesForType[0], type) : Activator.CreateInstance(type); } /// @@ -64,8 +65,8 @@ namespace Spring.Data.NHibernate.Bytecode /// A reference to the created object public object CreateInstance(Type type, bool nonPublic) { - string[] namesForType = listableObjectFactory.GetObjectNamesForType(type); - return namesForType.Length > 0 ? listableObjectFactory.GetObject(namesForType[0], type) : Activator.CreateInstance(type); + IList namesForType = listableObjectFactory.GetObjectNamesForType(type); + return namesForType.Count > 0 ? listableObjectFactory.GetObject(namesForType[0], type) : Activator.CreateInstance(type); } /// diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs index eb4c93e3..e8f48e86 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Bytecode/ReflectionOptimizer.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using NHibernate.Properties; @@ -57,8 +58,8 @@ namespace Spring.Data.NHibernate.Bytecode /// The new instance. public override object CreateInstance() { - string[] namesForType = listableObjectFactory.GetObjectNamesForType(mappedType); - if (namesForType.Length > 0) + IList namesForType = listableObjectFactory.GetObjectNamesForType(mappedType); + if (namesForType.Count > 0) { return listableObjectFactory.GetObject(namesForType[0], mappedType); } diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs index 00db9298..c87dfa35 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/LocalSessionFactoryObject.cs @@ -610,7 +610,7 @@ namespace Spring.Data.NHibernate // Register cache strategies for mapped entities. foreach (string className in this.entityCacheStrategies.Keys) { - String[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.entityCacheStrategies.GetProperty(className)); + string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.entityCacheStrategies.GetProperty(className)); if (strategyAndRegion.Length > 1) { config.SetCacheConcurrencyStrategy(className, strategyAndRegion[0], strategyAndRegion[1]); diff --git a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs index f160a3b5..0b8b1dcd 100644 --- a/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs +++ b/src/Spring/Spring.Data.NHibernate/Data/NHibernate/SessionFactoryUtils.cs @@ -22,6 +22,8 @@ using System; using System.Collections; +using System.Collections.Generic; + using Common.Logging; using NHibernate; using NHibernate.Connection; @@ -695,7 +697,7 @@ namespace Spring.Data.NHibernate { Type hibCommandType = db.CreateCommand().GetType(); - string[] providerNames = ctx.GetObjectNamesForType(typeof(DbProvider), true, false); + IList providerNames = ctx.GetObjectNamesForType(typeof(DbProvider), true, false); string hibCommandAQN = hibCommandType.AssemblyQualifiedName; foreach (string providerName in providerNames) { diff --git a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs index 699599ef..cf94a94f 100644 --- a/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs +++ b/src/Spring/Spring.Data/Data/Common/DbProviderFactory.cs @@ -19,6 +19,8 @@ #endregion using System; +using System.Collections.Generic; + using Common.Logging; using Spring.Context; using Spring.Context.Support; @@ -143,10 +145,10 @@ namespace Spring.Data.Common ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME }); } - string[] dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider)); + IList dbProviderNames = ctx.GetObjectNames(); if (log.IsInfoEnabled) { - log.Info(String.Format("{0} DbProviders Available. [{1}]", dbProviderNames.Length, StringUtils.ArrayToCommaDelimitedString(dbProviderNames))); + log.Info(String.Format("{0} DbProviders Available. [{1}]", dbProviderNames.Count, StringUtils.CollectionToCommaDelimitedString(dbProviderNames))); } } catch (Exception e) diff --git a/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs b/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs index 8f1f81be..41433802 100644 --- a/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs +++ b/src/Spring/Spring.Data/Data/Core/AdoTemplate.cs @@ -167,8 +167,7 @@ namespace Spring.Data.Core { throw new ArgumentException("DataReaderWrapper type must implement IDataReaderWrapper. Implemented interfaces on " + value.GetType().Name + "are [" + - StringUtils.ArrayToCommaDelimitedString( - ReflectionUtils.ToInterfaceArray(value)) + "]"); + StringUtils.CollectionToCommaDelimitedString(ReflectionUtils.ToInterfaceArray(value)) + "]"); } } diff --git a/src/Spring/Spring.Data/Transaction/Interceptor/TransactionProxyFactoryObject.cs b/src/Spring/Spring.Data/Transaction/Interceptor/TransactionProxyFactoryObject.cs index 703e893c..c4eaafab 100644 --- a/src/Spring/Spring.Data/Transaction/Interceptor/TransactionProxyFactoryObject.cs +++ b/src/Spring/Spring.Data/Transaction/Interceptor/TransactionProxyFactoryObject.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Collections.Specialized; using Spring.Aop; @@ -71,7 +72,7 @@ namespace Spring.Transaction.Interceptor { private TransactionInterceptor _transactionInterceptor; private object _target; - private Type[] _proxyInterfaces; + private IList _proxyInterfaces; private TruePointcut _pointcut; private object[] _preInterceptors; private object[] _postInterceptors; 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 52229572..99a8ce2a 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/ChainedExceptionListener.cs @@ -63,9 +63,9 @@ namespace Spring.Messaging.Nms.Connections /// Gets the exception listeners as an array. /// /// The exception listeners. - public IExceptionListener[] Listeners + public IList Listeners { - get { return listeners.ToArray(); } + get { return listeners; } } } } \ No newline at end of file diff --git a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs index ed2edf31..a7bae9d9 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/DefaultMessageQueueFactory.cs @@ -67,7 +67,7 @@ namespace Spring.Messaging.Core MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject(); mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate; applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo); - IDictionary caches = applicationContext.GetObjectsOfType(); + IDictionary caches = applicationContext.GetObjects(); foreach (KeyValuePair entry in caches) { 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 9b24f450..86799a2b 100644 --- a/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs +++ b/src/Spring/Spring.Messaging/Messaging/Core/MessageQueueMetadataCache.cs @@ -40,7 +40,7 @@ namespace Spring.Messaging.Core public void Initialize() { - IDictionary messageQueueDictionary = configurableApplicationContext.GetObjectsOfType(); + IDictionary messageQueueDictionary = configurableApplicationContext.GetObjects(); lock (itemStore.SyncRoot) { foreach (KeyValuePair entry in messageQueueDictionary) diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/QuartzJobObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/QuartzJobObject.cs index 54b6753f..e6dd48a3 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/QuartzJobObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/QuartzJobObject.cs @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +using System.Collections; + using Quartz; using Spring.Objects; @@ -68,8 +71,14 @@ namespace Spring.Scheduling.Quartz { ObjectWrapper bw = new ObjectWrapper(this); MutablePropertyValues pvs = new MutablePropertyValues(); - pvs.AddAll(context.Scheduler.Context); - pvs.AddAll(context.MergedJobDataMap); + foreach (DictionaryEntry entry in context.Scheduler.Context) + { + pvs.Add(entry.Key.ToString(), entry.Value); + } + foreach (DictionaryEntry entry in context.MergedJobDataMap) + { + pvs.Add(entry.Key.ToString(), entry.Value); + } bw.SetPropertyValues(pvs, true); } catch (SchedulerException ex) diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerAccessorObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerAccessorObject.cs index eff543f7..b30be10e 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerAccessorObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerAccessorObject.cs @@ -15,6 +15,7 @@ */ using System; +using System.Collections.Generic; using Quartz; using Quartz.Impl; @@ -132,8 +133,8 @@ namespace Spring.Scheduling.Quartz if (objectFactory is IListableObjectFactory) { IListableObjectFactory lbf = (IListableObjectFactory) objectFactory; - string[] objectNames = lbf.GetObjectNamesForType(typeof(IScheduler)); - for (int i = 0; i < objectNames.Length; i++) + IList objectNames = lbf.GetObjectNamesForType(typeof(IScheduler)); + for (int i = 0; i < objectNames.Count; i++) { IScheduler schedulerObject = (IScheduler)lbf.GetObject(objectNames[i]); if (schedulerName.Equals(schedulerObject.SchedulerName)) diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SpringObjectJobFactory.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SpringObjectJobFactory.cs index a213566b..40e27460 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SpringObjectJobFactory.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SpringObjectJobFactory.cs @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +using System.Collections; + using Quartz; using Quartz.Spi; using Spring.Objects; @@ -76,10 +79,19 @@ namespace Spring.Scheduling.Quartz MutablePropertyValues pvs = new MutablePropertyValues(); if (schedulerContext != null) { - pvs.AddAll(schedulerContext); + foreach (DictionaryEntry entry in schedulerContext) + { + pvs.Add(entry.Key.ToString(), entry.Value); + } + } + foreach (DictionaryEntry entry in bundle.JobDetail.JobDataMap) + { + pvs.Add(entry.Key.ToString(), entry.Value); + } + foreach (DictionaryEntry entry in bundle.Trigger.JobDataMap) + { + pvs.Add(entry.Key.ToString(), entry.Value); } - pvs.AddAll(bundle.JobDetail.JobDataMap); - pvs.AddAll(bundle.Trigger.JobDataMap); if (ignoredUnknownProperties != null) { for (int i = 0; i < ignoredUnknownProperties.Length; i++) diff --git a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs index b9e83ff5..e6ebc108 100644 --- a/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs +++ b/src/Spring/Spring.Services/ServiceModel/ServiceExporter.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.ServiceModel; @@ -491,12 +492,12 @@ namespace Spring.ServiceModel return attrs; } - protected override Type[] GetProxiableInterfaces(Type[] interfaces) + protected override IList GetProxiableInterfaces(IList interfaces) { if (contractInterface == null) { - Type[] proxiableInterfaces = base.GetProxiableInterfaces(interfaces); - if (proxiableInterfaces.Length > 1) + IList proxiableInterfaces = base.GetProxiableInterfaces(interfaces); + if (proxiableInterfaces.Count > 1) { throw new ArgumentException(String.Format( "ServiceExporter cannot export service type '{0}' as a WCF service because it implements multiple interfaces. Specify the contract interface to expose via the ContractInterface property.", @@ -558,7 +559,7 @@ namespace Spring.ServiceModel objectDefinition, null, null); - if (objectDefinition.PropertyValues.PropertyValues.Length == 0) + if (objectDefinition.PropertyValues.PropertyValues.Count == 0) { CustomAttributeBuilder cab = new CustomAttributeBuilder(ci.ConstructorInfo, ci.ArgInstances); diff --git a/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs b/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs index 2bebfbef..6ad87df6 100644 --- a/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs +++ b/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs @@ -487,7 +487,7 @@ namespace Spring.Web.Services /// The generated proxy class. public override Type BuildProxyType() { - if (Interfaces == null || Interfaces.Length == 0) + if (Interfaces == null || Interfaces.Count == 0) { throw new ArgumentException( "Web service client proxy must implement at least one interface."); diff --git a/src/Spring/Spring.Template.Velocity/Template/Velocity/Config/TemplateNamespaceParser.cs b/src/Spring/Spring.Template.Velocity/Template/Velocity/Config/TemplateNamespaceParser.cs index 8ecb2d52..0333de52 100644 --- a/src/Spring/Spring.Template.Velocity/Template/Velocity/Config/TemplateNamespaceParser.cs +++ b/src/Spring/Spring.Template.Velocity/Template/Velocity/Config/TemplateNamespaceParser.cs @@ -24,15 +24,14 @@ using System; using System.Collections; using System.Collections.Generic; using System.Xml; + using NVelocity.Runtime; -using NVelocity.Runtime.Resource.Loader; + using Spring.Core.TypeResolution; using Spring.Objects; -using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; -using Spring.Template.Velocity; using Spring.Util; #endregion @@ -226,8 +225,9 @@ namespace Spring.Template.Velocity.Config { /// a list of nv:file elements defining the paths to template files /// the properties used to initialize the velocity engine private void AppendFileLoaderProperties(XmlNodeList elements, IDictionary properties) { - IList paths = new List(elements.Count); - foreach (XmlElement element in elements) { + IList paths = new List(elements.Count); + foreach (XmlElement element in elements) + { paths.Add(GetAttributeValue(element, VelocityConstants.Path)); } properties.Add(RuntimeConstants.RESOURCE_LOADER, VelocityConstants.File); @@ -241,7 +241,7 @@ namespace Spring.Template.Velocity.Config { /// a list of nv:assembly elements defining the assemblies /// the properties used to initialize the velocity engine private void AppendAssemblyLoaderProperties(XmlNodeList elements, IDictionary properties) { - IList assemblies = new List(elements.Count); + IList assemblies = new List(elements.Count); foreach (XmlElement element in elements) { assemblies.Add(GetAttributeValue(element, VelocityConstants.Name)); } diff --git a/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs b/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs index 1e19b372..71a53144 100644 --- a/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs +++ b/src/Spring/Spring.Template.Velocity/Template/Velocity/VelocityEngineFactory.cs @@ -76,7 +76,7 @@ namespace Spring.Template.Velocity { private IDictionary velocityProperties = new Dictionary(); - private IList resourceLoaderPaths = new ArrayList(); + private IList resourceLoaderPaths = new List(); private IResourceLoader resourceLoader = new ConfigurableResourceLoader(); @@ -141,7 +141,8 @@ namespace Spring.Template.Velocity { /// /// /// - public IList ResourceLoaderPaths { + public IList ResourceLoaderPaths + { set { resourceLoaderPaths = value; } } @@ -287,12 +288,12 @@ namespace Spring.Template.Velocity { /// /// /// - protected void InitVelocityResourceLoader(VelocityEngine velocityEngine, ExtendedProperties extendedProperties, IList paths) { + protected void InitVelocityResourceLoader(VelocityEngine velocityEngine, ExtendedProperties extendedProperties, IList paths) { if (PreferFileSystemAccess) { // Try to load via the file system, fall back to SpringResourceLoader // (for hot detection of template changes, if possible). - IList resolvedPaths = new ArrayList(); + IList resolvedPaths = new List(); try { foreach (string path in paths) { IResource resource = ResourceLoader.GetResource(path); diff --git a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs index ed1d3c36..dcffac9b 100644 --- a/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs +++ b/src/Spring/Spring.Testing.Microsoft/Testing/Microsoft/AbstractSpringContextTests.cs @@ -156,7 +156,7 @@ namespace Spring.Testing.Microsoft } if (contextKey is string[]) { - return StringUtils.ArrayToCommaDelimitedString((string[]) contextKey); + return StringUtils.CollectionToCommaDelimitedString((string[])contextKey); } else { @@ -216,7 +216,7 @@ namespace Spring.Testing.Microsoft { if (logger.IsInfoEnabled) { - logger.Info("Loading config for: " + StringUtils.ArrayToCommaDelimitedString(locations)); + logger.Info("Loading config for: " + StringUtils.CollectionToCommaDelimitedString(locations)); } return new XmlApplicationContext(locations); } diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs index d5171402..e2eaa67b 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs @@ -19,13 +19,12 @@ #endregion using System; -using System.Collections; +using System.Collections.Generic; using System.Reflection; using NUnit.Framework; using Spring.Context; -using Spring.Context.Support; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -90,7 +89,7 @@ namespace Spring.Testing.NUnit /// /// Holds names of the fields that should be used for field injection. /// - protected string[] managedVariableNames; + protected IList managedVariableNames; private int loadCount = 0; /// @@ -231,7 +230,7 @@ namespace Spring.Testing.NUnit /// protected virtual void InitManagedVariableNames() { - ArrayList managedVarNames = new ArrayList(); + List managedVarNames = new List(); Type type = GetType(); do @@ -273,7 +272,7 @@ namespace Spring.Testing.NUnit type = type.BaseType; } while (type != typeof (AbstractDependencyInjectionSpringContextTests)); - this.managedVariableNames = (string[]) managedVarNames.ToArray(typeof (string)); + this.managedVariableNames = managedVarNames; } private static bool IsProtectedInstanceField(FieldInfo field) @@ -286,7 +285,7 @@ namespace Spring.Testing.NUnit /// protected virtual void InjectProtectedVariables() { - for (int i = 0; i < this.managedVariableNames.Length; i++) + for (int i = 0; i < this.managedVariableNames.Count; i++) { string fieldName = this.managedVariableNames[i]; Object obj = null; diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs index 8cbde4e1..b0e6f1e4 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractSpringContextTests.cs @@ -166,7 +166,7 @@ namespace Spring.Testing.NUnit } if (contextKey is string[]) { - return StringUtils.ArrayToCommaDelimitedString((string[]) contextKey); + return StringUtils.CollectionToCommaDelimitedString((string[])contextKey); } else { @@ -228,7 +228,7 @@ namespace Spring.Testing.NUnit { if (logger.IsInfoEnabled) { - logger.Info("Loading config for: " + StringUtils.ArrayToCommaDelimitedString(locations)); + logger.Info("Loading config for: " + StringUtils.CollectionToCommaDelimitedString(locations)); } return new XmlApplicationContext(locations); } diff --git a/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs b/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs index 535a11d7..e6d05617 100644 --- a/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs +++ b/src/Spring/Spring.Web/Context/Support/WebContextHandler.cs @@ -21,13 +21,12 @@ #region Imports using System; -using System.IO; -using System.Reflection; -using System.Web; +using System.Collections.Generic; using System.Web.Configuration; -using System.Web.Hosting; using System.Xml; + using Common.Logging; + using Spring.Util; #endregion @@ -86,11 +85,10 @@ namespace Spring.Context.Support /// Nesting contexts in webapplications is done by explicitly declaring /// spring context sections for each directory. /// - protected override void CreateChildContexts(IApplicationContext parentContext, object configContext, - XmlNode[] childContexts) + protected override void CreateChildContexts(IApplicationContext parentContext, object configContext, IList childContexts) { // disable child contexts in webapps - if (childContexts.Length > 0) + if (childContexts.Count > 0) { throw ConfigurationUtils.CreateConfigurationException( String.Format("Nested Child Contexts are not allowed in Web Applications. Use Web.config hierarchy instead."), childContexts[0]); @@ -100,9 +98,7 @@ namespace Spring.Context.Support /// /// Handles web specific details of context instantiation. /// - protected override IApplicationContext InstantiateContext(IApplicationContext parent, object configContext, - string contextName, Type contextType, - bool caseSensitive, string[] resources) + protected override IApplicationContext InstantiateContext(IApplicationContext parent, object configContext, string contextName, Type contextType, bool caseSensitive, IList resources) { // ASP.NET may scavenge it's configuration section cache if memory usage is too high. // Thus a handler may be called more than once for the same context. @@ -124,8 +120,7 @@ namespace Spring.Context.Support if (!vpath.EndsWith("/")) vpath = vpath + "/"; using (new HttpContextSwitch(vpath)) { - return - base.InstantiateContext(parent, configContext, contextName, contextType, caseSensitive, resources); + return base.InstantiateContext(parent, configContext, contextName, contextType, caseSensitive, resources); } } diff --git a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs index 1ad9317a..7d24d72d 100644 --- a/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs @@ -85,7 +85,7 @@ namespace Spring.Objects.Factory.Xml return objectName; } - protected override ObjectDefinitionHolder CreateObjectDefinitionHolder(XmlElement element, IConfigurableObjectDefinition definition, string objectName, string[] aliasesArray) + protected override ObjectDefinitionHolder CreateObjectDefinitionHolder(XmlElement element, IConfigurableObjectDefinition definition, string objectName, IList aliasesArray) { IWebObjectDefinition webDefinition = definition as IWebObjectDefinition; diff --git a/src/Spring/Spring.Web/Web/Support/ContextMonitor.cs b/src/Spring/Spring.Web/Web/Support/ContextMonitor.cs index f1a55b80..1f2fc0c0 100644 --- a/src/Spring/Spring.Web/Web/Support/ContextMonitor.cs +++ b/src/Spring/Spring.Web/Web/Support/ContextMonitor.cs @@ -19,6 +19,7 @@ #endregion using System; +using System.Collections.Generic; using System.IO; using System.Web; @@ -67,7 +68,7 @@ namespace Spring.Web.Support "Implementations of IApplicationContext must also implement IConfigurableApplicationContext"); } - string[] names = appContext.GetObjectDefinitionNames(); + IList names = appContext.GetObjectDefinitionNames(); foreach (string name in names) { RenderObjectDefinition(res.Output, name, appContext.ObjectFactory.GetObjectDefinition(name)); diff --git a/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs index 82e9ae41..69867053 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Config/AopNamespaceParserTests.cs @@ -20,6 +20,8 @@ #region Imports +using System.Collections.Generic; + using NUnit.Framework; using Spring.Aop.Framework; @@ -70,8 +72,8 @@ namespace Spring.Aop.Config IAdvised advised = testObject as IAdvised; Assert.IsNotNull(advised); - IAdvisor[] advisors = advised.Advisors; - Assert.IsTrue(advisors.Length > 0, "Advisors should not be empty"); + IList advisors = advised.Advisors; + Assert.IsTrue(advisors.Count > 0, "Advisors should not be empty"); } diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs index 0f9c5b22..fd412d51 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreatorTests.cs @@ -1,25 +1,26 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion using System; using System.Collections; +using System.Collections.Generic; using AopAlliance.Aop; using NUnit.Framework; using Spring.Objects.Factory.Config; @@ -37,7 +38,7 @@ namespace Spring.Aop.Framework.AutoProxy { public ArrayList CheckedAdvisors = new ArrayList(); - public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) + public IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) { return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null); } @@ -87,8 +88,8 @@ namespace Spring.Aop.Framework.AutoProxy TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator(); apc.ObjectFactory = of; - object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget"); - Assert.AreEqual(1, advisors.Length); + IList advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget"); + Assert.AreEqual(1, advisors.Count); Assert.AreEqual( "RegularAdvisor", ((TestAdvisor)advisors[0]).Name ); Assert.AreEqual(1, apc.CheckedAdvisors.Count); diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs index 0730c08d..318a1928 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AbstractAutoProxyCreatorTests.cs @@ -1,24 +1,25 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion using System; +using System.Collections.Generic; using System.Runtime.Remoting; using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Proxies; @@ -120,13 +121,13 @@ namespace Spring.Aop.Framework.AutoProxy this.ObjectFactory = objectFactory; } - protected override object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) + protected override IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) { if (typeof(IFactoryObject).IsAssignableFrom(targetType)) { return DO_NOT_PROXY; } - return new object[] { NopInterceptor }; + return new List { NopInterceptor }; } } 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 194208e5..6598d9ef 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/AdvisorAutoProxyCreatorCircularReferencesTests.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Reflection; using Common.Logging; @@ -93,10 +94,10 @@ namespace Spring.Aop.Framework.AutoProxy _logger.Trace("Created instance"); } - protected override object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) + protected override IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName, ITargetSource customTargetSource) { _logger.Trace("GetAdvicesAndAdvisorsForObject begin"); - object[] advices = base.GetAdvicesAndAdvisorsForObject(targetType, targetName, customTargetSource); + IList advices = base.GetAdvicesAndAdvisorsForObject(targetType, targetName, customTargetSource); _logger.Trace("GetAdvicesAndAdvisorsForObject end"); return advices; } diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs index 4fa6fe12..0617325a 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/AutoProxy/InfrastructureAdvisorAutoProxyCreator.cs @@ -1,24 +1,25 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion using System; +using System.Collections.Generic; using AopAlliance.Aop; using NUnit.Framework; using Spring.Objects.Factory.Config; @@ -34,7 +35,7 @@ namespace Spring.Aop.Framework.AutoProxy { public class TestAdvisorAutoProxyCreator : InfrastructureAdvisorAutoProxyCreator { - public object[] GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) + public IList GetAdvicesAndAdvisorsForObject(Type targetType, string targetName) { return base.GetAdvicesAndAdvisorsForObject(targetType, targetName, null); } @@ -78,8 +79,8 @@ namespace Spring.Aop.Framework.AutoProxy TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator(); apc.ObjectFactory = of; - object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof(object), "dummyTarget"); - Assert.AreEqual(1, advisors.Length); + IList advisors = apc.GetAdvicesAndAdvisorsForObject(typeof(object), "dummyTarget"); + Assert.AreEqual(1, advisors.Count); Assert.AreEqual("InfrastructureAdvisor", ((TestAdvisor)advisors[0]).Name); } } diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs index fd2f7138..0d5c0b55 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/DynamicProxy/AbstractAopProxyTests.cs @@ -1222,7 +1222,7 @@ namespace Spring.Aop.Framework.DynamicProxy IAdvised a1 = (IAdvised)p; IAdvised a2 = (IAdvised)p2; // Check we can manipulate state of p2 - Assert.AreEqual(a1.Advisors.Length, a2.Advisors.Length); + Assert.AreEqual(a1.Advisors.Count, a2.Advisors.Count); // This should work as SerializablePerson is equal Assert.AreEqual(p, p2, "Proxies should be equal, even after one was serialized"); @@ -1706,7 +1706,7 @@ namespace Spring.Aop.Framework.DynamicProxy Assert.AreEqual(2, ni.Count); IAdvised advised = (IAdvised)ito; - Assert.AreEqual(1, advised.Advisors.Length, "Have 1 advisor"); + Assert.AreEqual(1, advised.Advisors.Count, "Have 1 advisor"); Assert.AreEqual(ni, advised.Advisors[0].Advice); NopInterceptor ni2 = new NopInterceptor(); advised.AddAdvice(1, ni2); @@ -1750,7 +1750,7 @@ namespace Spring.Aop.Framework.DynamicProxy // Check it still works: proxy factory state shouldn't have been corrupted Assert.AreEqual(target.Age, proxied.Age); - Assert.AreEqual(1, ((IAdvised)proxied).Advisors.Length); + Assert.AreEqual(1, ((IAdvised)proxied).Advisors.Count); } [Test(Description = "Check that casting to Advised can't get around advice freeze.")] @@ -1778,7 +1778,7 @@ namespace Spring.Aop.Framework.DynamicProxy // Check it still works: proxy factory state shouldn't have been corrupted Assert.AreEqual(target.Age, proxied.Age); - Assert.AreEqual(1, advised.Advisors.Length); + Assert.AreEqual(1, advised.Advisors.Count); } [Test] @@ -1805,13 +1805,13 @@ namespace Spring.Aop.Framework.DynamicProxy } // Didn't get removed - Assert.AreEqual(1, advised.Advisors.Length); + Assert.AreEqual(1, advised.Advisors.Count); pf.IsFrozen = false; // Can now remove it advised.RemoveAdvisor(0); // Check it still works: proxy factory state shouldn't have been corrupted Assert.AreEqual(target.Age, proxied.Age); - Assert.AreEqual(0, advised.Advisors.Length); + Assert.AreEqual(0, advised.Advisors.Count); } [Test(Description = "Check that the string is informative.")] diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryObjectTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryObjectTests.cs index 31cb7b55..de3b5d0d 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryObjectTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryObjectTests.cs @@ -154,11 +154,11 @@ namespace Spring.Aop.Framework IAdvised pc1 = (IAdvised)test1; IAdvised pc2 = (IAdvised)test1_1; Assert.AreEqual(pc1.Advisors, pc2.Advisors); - int oldLength = pc1.Advisors.Length; + int oldLength = pc1.Advisors.Count; NopInterceptor di = new NopInterceptor(); pc1.AddAdvice(1, di); Assert.AreEqual(pc1.Advisors, pc2.Advisors); - Assert.AreEqual(oldLength + 1, pc2.Advisors.Length, "Now have one more advisor"); + Assert.AreEqual(oldLength + 1, pc2.Advisors.Count, "Now have one more advisor"); Assert.AreEqual(di.Count, 0); test1.Age = (5); Assert.AreEqual(test1_1.Age, test1.Age); @@ -224,12 +224,12 @@ namespace Spring.Aop.Framework string dummy = to.Name; IAdvised config = (IAdvised)to; - Assert.AreEqual(1, config.Advisors.Length, "Object should have only one advisors"); + Assert.AreEqual(1, config.Advisors.Count, "Object should have only one advisors"); Exception ex = new NotSupportedException("Invoke"); // Add evil interceptor to head of list config.AddAdvice(0, new EvilMethodInterceptor(ex)); - Assert.AreEqual(2, config.Advisors.Length, "The advisor count is wrong after adding an advisor programmatically."); + Assert.AreEqual(2, config.Advisors.Count, "The advisor count is wrong after adding an advisor programmatically."); try { @@ -266,16 +266,16 @@ namespace Spring.Aop.Framework IIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)); // add to front of introduction chain - int oldCount = config.Introductions.Length; + int oldCount = config.Introductions.Count; config.AddIntroduction(0, advisor); - Assert.IsTrue(config.Introductions.Length == oldCount + 1); + Assert.IsTrue(config.Introductions.Count == oldCount + 1); ITimeStamped ts2 = (ITimeStamped)factory.GetObject("test1"); Assert.IsTrue(ts2.TimeStamp == new DateTime(time)); // Can remove config.RemoveIntroduction(advisor); - Assert.IsTrue(config.Introductions.Length == oldCount); + Assert.IsTrue(config.Introductions.Count == oldCount); // Existing reference will still work object o = ts2.TimeStamp; @@ -292,9 +292,9 @@ namespace Spring.Aop.Framework } // Now check non-effect of removing interceptor that isn't there - oldCount = config.Advisors.Length; + oldCount = config.Advisors.Count; config.RemoveAdvice(new DebugAdvice()); - Assert.IsTrue(config.Advisors.Length == oldCount); + Assert.IsTrue(config.Advisors.Count == oldCount); ITestObject it = (ITestObject)ts2; DebugAdvice debugInterceptor = new DebugAdvice(); @@ -330,16 +330,16 @@ namespace Spring.Aop.Framework IIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)); // add to front of introduction chain - int oldCount = config.Introductions.Length; + int oldCount = config.Introductions.Count; config.AddIntroduction(0, advisor); - Assert.IsTrue(config.Introductions.Length == oldCount + 1); + Assert.IsTrue(config.Introductions.Count == oldCount + 1); ITimeStamped ts2 = (ITimeStamped)factory.GetObject("test2"); Assert.IsTrue(ts2.TimeStamp == new DateTime(time)); // Can remove config.RemoveIntroduction(advisor); - Assert.IsTrue(config.Introductions.Length == oldCount); + Assert.IsTrue(config.Introductions.Count == oldCount); // Existing reference will still work object o = ts2.TimeStamp; @@ -358,9 +358,9 @@ namespace Spring.Aop.Framework ITestObject it = (ITestObject)factory.GetObject("test2"); config = (IAdvised)it; - oldCount = config.Advisors.Length; + oldCount = config.Advisors.Count; config.RemoveAdvice(new DebugAdvice()); - Assert.IsTrue(config.Advisors.Length == oldCount); + Assert.IsTrue(config.Advisors.Count == oldCount); DebugAdvice debugInterceptor = new DebugAdvice(); config.AddAdvice(0, debugInterceptor); @@ -462,10 +462,10 @@ namespace Spring.Aop.Framework ProxyFactoryObject pfb = (ProxyFactoryObject)factory.GetObject("&validGlobals"); pfb.GetObject(); // for creation - Assert.AreEqual(2, pfb.Advisors.Length, "Proxy should have 1 global and 1 explicit advisor"); - Assert.AreEqual(1, pfb.Introductions.Length, "Proxy should have 1 global introduction"); + Assert.AreEqual(2, pfb.Advisors.Count, "Proxy should have 1 global and 1 explicit advisor"); + Assert.AreEqual(1, pfb.Introductions.Count, "Proxy should have 1 global introduction"); - agi.GlobalsAdded = ((IAdvised)agi).Introductions.Length; + agi.GlobalsAdded = ((IAdvised)agi).Introductions.Count; Assert.IsTrue(agi.GlobalsAdded == 1); IApplicationEventListener l = (IApplicationEventListener)factory.GetObject("validGlobals"); diff --git a/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryTests.cs b/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryTests.cs index e4333a08..a2b2b673 100644 --- a/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryTests.cs +++ b/test/Spring/Spring.Aop.Tests/Aop/Framework/ProxyFactoryTests.cs @@ -399,7 +399,7 @@ namespace Spring.Aop.Framework advSup.AddAdvisor(advisor1); advSup.AddAdvisor(advisor1); - Assert.AreEqual(1, advSup.Advisors.Length); + Assert.AreEqual(1, advSup.Advisors.Count); } private class AnonymousClassTimeStamped : ITimeStamped @@ -454,7 +454,7 @@ namespace Spring.Aop.Framework // Extend to get new interface TestObjectSubclass raw = new TestObjectSubclass(); ProxyFactory factory = new ProxyFactory(raw); - Assert.AreEqual(8, factory.Interfaces.Length, "Found correct number of interfaces"); + Assert.AreEqual(8, factory.Interfaces.Count, "Found correct number of interfaces"); //System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ",")); ITestObject tb = (ITestObject)factory.GetProxy(); Assert.IsTrue(tb is IOther, "Picked up secondary interface"); @@ -465,14 +465,14 @@ namespace Spring.Aop.Framework DateTime t = new DateTime(2004, 8, 1); TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t); - Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/")); + Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/")); //factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped))); factory.AddIntroduction( new DefaultIntroductionAdvisor(ti, typeof(ITimeStamped)) ); - Console.WriteLine(StringUtils.ArrayToDelimitedString(factory.Interfaces, "/")); + Console.WriteLine(StringUtils.CollectionToDelimitedString(factory.Interfaces, "/")); ITimeStamped ts = (ITimeStamped)factory.GetProxy(); Assert.IsTrue(ts.TimeStamp == t); diff --git a/test/Spring/Spring.Aop.Tests/Aspects/Exception/CaptureOutputLoggerFactoryAdapter.cs b/test/Spring/Spring.Aop.Tests/Aspects/Exception/CaptureOutputLoggerFactoryAdapter.cs index a3e999af..47544653 100644 --- a/test/Spring/Spring.Aop.Tests/Aspects/Exception/CaptureOutputLoggerFactoryAdapter.cs +++ b/test/Spring/Spring.Aop.Tests/Aspects/Exception/CaptureOutputLoggerFactoryAdapter.cs @@ -1,9 +1,9 @@ using System; -using System.Collections; -using System.Collections.Specialized; +using System.Collections.Generic; using System.Diagnostics; + using Common.Logging; using Common.Logging.Simple; @@ -44,9 +44,9 @@ namespace Spring.Aspects.Exceptions System.Diagnostics.Trace.Listeners.Remove(listener); } - private IList logMessages = new ArrayList(); + private IList logMessages = new List(); - public IList LogMessages + public IList LogMessages { get { return logMessages; } set { logMessages = value; } diff --git a/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs index fbac52d7..b2141921 100644 --- a/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs +++ b/test/Spring/Spring.Core.Tests/Context/Support/ApplicationObjectSupportTests.cs @@ -119,28 +119,27 @@ namespace Spring.Context.Support return null; } - public string[] GetObjectNamesForType(Type type) + public IList GetObjectNamesForType(Type type) { return null; } - public string[] GetObjectNamesForType() + public IList GetObjectNames() { return null; } - public string[] GetObjectNamesForType( - Type type, bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNamesForType(Type type, bool includePrototypes, bool includeFactoryObjects) { return null; } - public string[] GetObjectNamesForType(bool includePrototypes, bool includeFactoryObjects) + public IList GetObjectNames(bool includePrototypes, bool includeFactoryObjects) { return null; } - string[] IListableObjectFactory.GetObjectDefinitionNames() + IList IListableObjectFactory.GetObjectDefinitionNames() { return null; } @@ -150,7 +149,7 @@ namespace Spring.Context.Support return null; } - public IDictionary GetObjectsOfType() + public IDictionary GetObjects() { return null; } @@ -160,7 +159,7 @@ namespace Spring.Context.Support return null; } - public IDictionary GetObjectsOfType(bool includePrototypes, bool includeFactoryObjects) + public IDictionary GetObjects(bool includePrototypes, bool includeFactoryObjects) { return null; } @@ -199,7 +198,7 @@ namespace Spring.Context.Support return false; } - public string[] GetAliases(string name) + public IList GetAliases(string name) { return null; } diff --git a/test/Spring/Spring.Core.Tests/Core/TypeResolution/TypeResolutionUtilsTests.cs b/test/Spring/Spring.Core.Tests/Core/TypeResolution/TypeResolutionUtilsTests.cs index 8d3bda36..c5f6ff5b 100644 --- a/test/Spring/Spring.Core.Tests/Core/TypeResolution/TypeResolutionUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/TypeResolution/TypeResolutionUtilsTests.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using System.Reflection; using NUnit.Framework; @@ -75,9 +76,9 @@ namespace Spring.Core.TypeResolution { Type[] expected = new Type[] { typeof(IFoo) }; string[] input = new string[] { typeof(IFoo).AssemblyQualifiedName }; - Type[] actual = TypeResolutionUtils.ResolveInterfaceArray(input); + IList actual = TypeResolutionUtils.ResolveInterfaceArray(input); Assert.IsNotNull(actual); - Assert.AreEqual(expected.Length, actual.Length); + Assert.AreEqual(expected.Length, actual.Count); Assert.AreEqual(expected[0], actual[0]); } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractListableObjectFactoryTests.cs index 8e084fff..7868fb2f 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractListableObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractListableObjectFactoryTests.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections.Generic; using NUnit.Framework; @@ -62,10 +63,10 @@ namespace Spring.Objects.Factory { protected internal void AssertCount (int count) { - string [] defnames = ListableObjectFactory.GetObjectDefinitionNames (); + IList defnames = ListableObjectFactory.GetObjectDefinitionNames (); Assert.IsTrue ( - defnames.Length == count, - string.Format ("We should have {0} objects, not {1}.", count, defnames.Length)); + defnames.Count == count, + string.Format ("We should have {0} objects, not {1}.", count, defnames.Count)); } [Test] @@ -76,19 +77,19 @@ namespace Spring.Objects.Factory { public virtual void AssertTestObjectCount (int count) { - string [] defnames = + IList defnames = ListableObjectFactory.GetObjectNamesForType (typeof (TestObject)); Assert.IsTrue ( - defnames.Length == count, - string.Format ("We should have {0} objects for class {1}, not {2}.", count, typeof (TestObject).FullName, defnames.Length)); + defnames.Count == count, + string.Format ("We should have {0} objects for class {1}, not {2}.", count, typeof (TestObject).FullName, defnames.Count)); } [Test] public virtual void GetDefinitionsForNoSuchClass () { - string[] defnames = + IList defnames = ListableObjectFactory.GetObjectNamesForType (typeof (string)); - Assert.IsTrue (defnames.Length == 0, "No string definitions"); + Assert.IsTrue (defnames.Count == 0, "No string definitions"); } /// @@ -101,7 +102,7 @@ namespace Spring.Objects.Factory { { int count = ListableObjectFactory.GetObjectNamesForType ( - typeof (IFactoryObject)).Length; + typeof (IFactoryObject)).Count; Assert.IsTrue ( count == 2, string.Format ("Should have 2 factories, not {0}.", count)); diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractObjectFactoryTests.cs index 3d0e8830..61b69a01 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/AbstractObjectFactoryTests.cs @@ -80,7 +80,7 @@ namespace Spring.Objects.Factory Assert.IsTrue(-1 < ex.Message.IndexOf("already registered")); } - Assert.AreEqual(1, of.GetAliases("nAmE").Length); + Assert.AreEqual(1, of.GetAliases("nAmE").Count); Assert.AreEqual(testObject, of.GetObject("nAmE")); Assert.AreEqual(testObject, of.GetObject("ALIAS")); } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs index 6457253e..c9b66d4f 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs @@ -146,7 +146,7 @@ namespace Spring.Objects.Factory def.FactoryMethodName = "CreateTestObject"; DefaultListableObjectFactory lof = new DefaultListableObjectFactory(); lof.RegisterObjectDefinition("factoryObject", def); - IDictionary objs = lof.GetObjectsOfType(); + IDictionary objs = lof.GetObjects(); Assert.AreEqual(1, objs.Count); } @@ -160,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(); + IDictionary objs = lof.GetObjects(); Assert.AreEqual(1, objs.Count); } @@ -404,8 +404,7 @@ namespace Spring.Objects.Factory #region IInstantiationAwareObjectPostProcessor Members - public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName) + public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName) { return pvs; } @@ -455,8 +454,7 @@ namespace Spring.Objects.Factory #region IInstantiationAwareObjectPostProcessor Members - public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, - string objectName) + public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, IList pis, object objectInstance, string objectName) { return pvs; } @@ -532,7 +530,7 @@ namespace Spring.Objects.Factory { IListableObjectFactory lof = new DefaultListableObjectFactory(); Assert.IsTrue(lof.GetObjectDefinitionNames() != null, "No objects defined --> array != null"); - Assert.IsTrue(lof.GetObjectDefinitionNames().Length == 0, "No objects defined after no arg constructor"); + Assert.IsTrue(lof.GetObjectDefinitionNames().Count == 0, "No objects defined after no arg constructor"); Assert.IsTrue(lof.ObjectDefinitionCount == 0, "No objects defined after no arg constructor"); } @@ -640,7 +638,7 @@ namespace Spring.Objects.Factory lof.RegisterSingleton("singletonObject", singletonObject); Assert.IsTrue(lof.ContainsObject("singletonObject")); Assert.IsTrue(lof.IsSingleton("singletonObject")); - Assert.AreEqual(0, lof.GetAliases("singletonObject").Length); + Assert.AreEqual(0, lof.GetAliases("singletonObject").Count); DependenciesObject test = (DependenciesObject)lof.GetObject("test"); Assert.AreEqual(singletonObject, lof.GetObject("singletonObject")); Assert.AreEqual(singletonObject, test.Spouse); @@ -1751,8 +1749,8 @@ namespace Spring.Objects.Factory DefaultListableObjectFactory of = new DefaultListableObjectFactory(); of.RegisterObjectDefinition("mod", new RootObjectDefinition(typeof(A))); - string[] names = of.GetObjectNamesForType(typeof (ISerializable), false, false); - Assert.IsNotEmpty(names); + IList names = of.GetObjectNamesForType(typeof (ISerializable), false, false); + Assert.IsNotEmpty((ICollection) names); Assert.AreEqual("&mod", names[0]); } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs index c3471d00..1b138e43 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/ObjectFactoryUtilsTests.cs @@ -72,7 +72,7 @@ namespace Spring.Objects.Factory [Test] public void ObjectNamesIncludingAncestors() { - IList names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(_factory); + IList names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(_factory); Assert.AreEqual(6, names.Count); } @@ -89,8 +89,8 @@ namespace Spring.Objects.Factory mocks.ReplayAll(); - string[] names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(of); - Assert.AreEqual(5, names.Length); + IList names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(of); + Assert.AreEqual(5, names.Count); Assert.AreEqual(new string[] { "objA","objB","objC","obj2A","obj2C" }, names); mocks.VerifyAll(); @@ -99,7 +99,7 @@ namespace Spring.Objects.Factory [Test] public void ObjectNamesForTypeIncludingAncestors() { - IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, typeof (ITestObject)); + IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, typeof (ITestObject)); // includes 2 TestObjects from IFactoryObjects (DummyFactory definitions) Assert.AreEqual(4, names.Count); Assert.IsTrue(names.Contains("test")); @@ -116,7 +116,7 @@ namespace Spring.Objects.Factory DefaultListableObjectFactory child = new DefaultListableObjectFactory(root); child.RegisterObjectDefinition("excludeLocalObject", new RootObjectDefinition(typeof(Hashtable))); - IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof (ArrayList)); + IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof (ArrayList)); // "excludeLocalObject" matches on the parent, but not the local object definition Assert.AreEqual(0, names.Count); @@ -139,8 +139,8 @@ namespace Spring.Objects.Factory mocks.ReplayAll(); - string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE); - Assert.AreEqual(5, names.Length); + IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE); + Assert.AreEqual(5, names.Count); Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names); mocks.VerifyAll(); @@ -160,8 +160,8 @@ namespace Spring.Objects.Factory mocks.ReplayAll(); - string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false); - Assert.AreEqual(5, names.Length); + IList names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false); + Assert.AreEqual(5, names.Count); Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names); diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ChildObjectDefinitionTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ChildObjectDefinitionTests.cs index b90a3c58..5cd5d457 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ChildObjectDefinitionTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ChildObjectDefinitionTests.cs @@ -65,7 +65,7 @@ namespace Spring.Objects.Factory.Support "ParentName property not initialized correctly by ctor."); Assert.IsNotNull(def.PropertyValues, "PropertyValues must be init'd to a non-null collection if not explicitly supplied."); - Assert.AreEqual(0, def.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, def.PropertyValues.PropertyValues.Count, "PropertyValues must be init'd to an empty collection if not explicitly supplied."); } } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/DefaultObjectDefinitionFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/DefaultObjectDefinitionFactoryTests.cs index ecb3e754..7666373d 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/DefaultObjectDefinitionFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/DefaultObjectDefinitionFactoryTests.cs @@ -44,7 +44,7 @@ namespace Spring.Objects.Factory.Support typeof (TestObject).FullName, null, AppDomain.CurrentDomain); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof (TestObject), definition.ObjectType); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in."); @@ -59,7 +59,7 @@ namespace Spring.Objects.Factory.Support typeof (TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof (TestObject), definition.ObjectType); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in."); @@ -74,7 +74,7 @@ namespace Spring.Objects.Factory.Support typeof (TestObject).FullName, null, null); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof (TestObject).FullName, definition.ObjectTypeName); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in."); diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/RootObjectDefinitionTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/RootObjectDefinitionTests.cs index 8b113d9e..a84d9f4e 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/RootObjectDefinitionTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/RootObjectDefinitionTests.cs @@ -89,7 +89,7 @@ namespace Spring.Objects.Factory.Support Assert.AreEqual( "Ohhh", def.ResourceDescription ); Assert.IsTrue( def.HasConstructorArgumentValues ); Assert.AreEqual( other.ConstructorArgumentValues.ArgumentCount, def.ConstructorArgumentValues.ArgumentCount ); - Assert.AreEqual( other.PropertyValues.PropertyValues.Length, def.PropertyValues.PropertyValues.Length ); + Assert.AreEqual( other.PropertyValues.PropertyValues.Count, def.PropertyValues.PropertyValues.Count ); Assert.AreEqual( other.EventHandlerValues.Events.Count, def.EventHandlerValues.Events.Count ); } @@ -148,14 +148,14 @@ namespace Spring.Objects.Factory.Support Assert.AreEqual( "InitChild", rod.InitMethodName ); Assert.AreEqual( "DestroyChild", rod.DestroyMethodName ); Assert.AreEqual( DependencyCheckingMode.None, rod.DependencyCheck ); - Assert.AreEqual( 4, rod.DependsOn.Length); + Assert.AreEqual( 4, rod.DependsOn.Count); Assert.AreEqual( false, rod.IsAbstract ); Assert.AreEqual( false, rod.IsLazyInit ); Assert.AreEqual( "ChildFactoryMethodName", rod.FactoryMethodName ); Assert.AreEqual( "ChildFactoryObjectName", rod.FactoryObjectName ); Assert.AreEqual( "ChildResourceDescription", rod.ResourceDescription ); Assert.AreEqual( 2, rod.ConstructorArgumentValues.ArgumentCount ); - Assert.AreEqual( 2, rod.PropertyValues.PropertyValues.Length ); + Assert.AreEqual( 2, rod.PropertyValues.PropertyValues.Count ); Assert.AreEqual( "Val1", rod.PropertyValues.GetPropertyValue("Prop1").Value); Assert.AreEqual( 50, rod.PropertyValues.GetPropertyValue("Age").Value); Assert.AreEqual( 2, rod.EventHandlerValues.Events.Count ); @@ -183,7 +183,7 @@ namespace Spring.Objects.Factory.Support "Must be empty if null was passed to the ctor." ); Assert.IsNotNull( def.PropertyValues, "Must never be null, but rather just empty." ); - Assert.AreEqual( 0, def.PropertyValues.PropertyValues.Length, + Assert.AreEqual( 0, def.PropertyValues.PropertyValues.Count, "Must be empty if null was passed to the ctor." ); } } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/UnsupportedObjectDefinitionImplementation.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/UnsupportedObjectDefinitionImplementation.cs index 7a9272a8..6e45ad54 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/UnsupportedObjectDefinitionImplementation.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/UnsupportedObjectDefinitionImplementation.cs @@ -19,6 +19,8 @@ #endregion using System; +using System.Collections.Generic; + using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -109,7 +111,7 @@ namespace Spring.Objects.Factory get { throw new NotImplementedException(); } } - public string[] DependsOn + public IList DependsOn { get { throw new NotImplementedException(); } } diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlListableObjectFactoryTests.cs index 44abdc76..c2b1987d 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlListableObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlListableObjectFactoryTests.cs @@ -22,6 +22,8 @@ using System; using System.Collections; +using System.Collections.Generic; + using NUnit.Framework; using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; @@ -83,11 +85,11 @@ namespace Spring.Objects.Factory.Xml protected void SetUp() { parent = new DefaultListableObjectFactory(); - IDictionary m = new Hashtable(); + IDictionary m = new Dictionary(); m["name"] = "Albert"; parent.RegisterObjectDefinition("father", new RootObjectDefinition(typeof (TestObject), new MutablePropertyValues(m))); - m = new Hashtable(); - m["name"] = "Roderick"; + m = new Dictionary(); + m["name"] = "Roderick"; parent.RegisterObjectDefinition("rod", new RootObjectDefinition(typeof (TestObject), new MutablePropertyValues(m))); // for testing dynamic ctor arguments + parent.GetObject() call propagation diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs index e2088741..fa683b02 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectCollectionTests.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Text; using Common.Logging; @@ -198,12 +199,12 @@ namespace Spring.Objects.Factory.Xml { IResource resource = new ReadOnlyXmlTestResource("collections.xml", GetType()); XmlObjectFactory xof = new XmlObjectFactory(resource); - IList objectNames = xof.GetObjectDefinitionNames(); + IList objectNames = xof.GetObjectDefinitionNames(); TestObject tb1 = (TestObject) xof.GetObject("aliased"); TestObject alias1 = (TestObject) xof.GetObject("myalias"); Assert.IsTrue(tb1 == alias1); - IList tb1Aliases = xof.GetAliases("aliased"); + IList tb1Aliases = xof.GetAliases("aliased"); Assert.AreEqual(1, tb1Aliases.Count); Assert.IsTrue(tb1Aliases.Contains("myalias")); Assert.IsTrue(objectNames.Contains("aliased")); @@ -214,7 +215,7 @@ namespace Spring.Objects.Factory.Xml TestObject alias3 = (TestObject) xof.GetObject("alias2"); Assert.IsTrue(tb2 == alias2); Assert.IsTrue(tb2 == alias3); - IList tb2Aliases = xof.GetAliases("multiAliased"); + IList tb2Aliases = xof.GetAliases("multiAliased"); Assert.AreEqual(2, tb2Aliases.Count); Assert.IsTrue(tb2Aliases.Contains("alias1")); Assert.IsTrue(tb2Aliases.Contains("alias2")); @@ -228,7 +229,7 @@ namespace Spring.Objects.Factory.Xml Assert.IsTrue(tb3 == alias4); Assert.IsTrue(tb3 == alias5); - IList tb3Aliases = xof.GetAliases("aliasWithoutId1"); + IList tb3Aliases = xof.GetAliases("aliasWithoutId1"); Assert.AreEqual(2, tb2Aliases.Count); Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId2")); Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId3")); diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs index d3f14717..45aabde2 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs @@ -350,7 +350,7 @@ namespace Spring.Objects.Factory.Xml Assert.AreEqual(AutoWiringMode.No, od2.AutowireMode); Assert.AreEqual("init", od2.InitMethodName); Assert.AreEqual("destroy", od2.DestroyMethodName); - Assert.AreEqual(1, od2.DependsOn.Length); + Assert.AreEqual(1, od2.DependsOn.Count); Assert.AreEqual("test1", od2.DependsOn[0]); Assert.AreEqual(DependencyCheckingMode.Simple, od2.DependencyCheck); } 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 65674bee..a4b772bd 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs @@ -459,9 +459,9 @@ namespace Spring.Objects.Factory.Xml "; stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); XmlObjectFactory factory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty)); - string[] names = factory.GetObjectDefinitionNames(); + IList names = factory.GetObjectDefinitionNames(); // mmm, how is one to test this? I have no idea what the generated name is... - Assert.AreEqual(2, names.Length, "Should have got two object names, one of which is autogenerated."); + Assert.AreEqual(2, names.Count, "Should have got two object names, one of which is autogenerated."); } /// diff --git a/test/Spring/Spring.Core.Tests/Objects/MutablePropertyValuesTests.cs b/test/Spring/Spring.Core.Tests/Objects/MutablePropertyValuesTests.cs index 37aeb084..4fa0b848 100644 --- a/test/Spring/Spring.Core.Tests/Objects/MutablePropertyValuesTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/MutablePropertyValuesTests.cs @@ -20,8 +20,7 @@ #region Imports -using System; -using System.Collections; +using System.Collections.Generic; using NUnit.Framework; @@ -70,16 +69,16 @@ namespace Spring.Objects root.Add (new PropertyValue ("Name", "Fiona Apple")); root.Add (new PropertyValue ("Age", 24)); MutablePropertyValues props = new MutablePropertyValues (root); - Assert.AreEqual (2, props.PropertyValues.Length); + Assert.AreEqual (2, props.PropertyValues.Count); } [Test] public void InstantiationWithNulls () { - MutablePropertyValues props = new MutablePropertyValues ((IDictionary) null); - Assert.AreEqual (0, props.PropertyValues.Length); + MutablePropertyValues props = new MutablePropertyValues ((IDictionary) null); + Assert.AreEqual (0, props.PropertyValues.Count); MutablePropertyValues props2 = new MutablePropertyValues ((IPropertyValues) null); - Assert.AreEqual (0, props2.PropertyValues.Length); + Assert.AreEqual (0, props2.PropertyValues.Count); } [Test] @@ -89,7 +88,7 @@ namespace Spring.Objects props.AddAll (new PropertyValue [] { new PropertyValue ("Name", "Fiona Apple"), new PropertyValue ("Age", 24)}); - Assert.AreEqual (2, props.PropertyValues.Length); + Assert.AreEqual (2, props.PropertyValues.Count); } [Test] @@ -98,8 +97,8 @@ namespace Spring.Objects MutablePropertyValues props = new MutablePropertyValues (); props.Add (new PropertyValue ("Name", "Fiona Apple")); props.Add (new PropertyValue ("Age", 24)); - props.AddAll ((IList) null); - Assert.AreEqual (2, props.PropertyValues.Length); + props.AddAll ((IList) null); + Assert.AreEqual (2, props.PropertyValues.Count); } [Test] @@ -108,9 +107,9 @@ namespace Spring.Objects MutablePropertyValues props = new MutablePropertyValues (); props.Add (new PropertyValue ("Name", "Fiona Apple")); props.Add (new PropertyValue ("Age", 24)); - Assert.AreEqual (2, props.PropertyValues.Length); + Assert.AreEqual (2, props.PropertyValues.Count); props.Remove ("name"); - Assert.AreEqual (1, props.PropertyValues.Length); + Assert.AreEqual (1, props.PropertyValues.Count); } [Test] @@ -120,9 +119,9 @@ namespace Spring.Objects PropertyValue propName = new PropertyValue ("Name", "Fiona Apple"); props.Add (propName); props.Add (new PropertyValue ("Age", 24)); - Assert.AreEqual (2, props.PropertyValues.Length); + Assert.AreEqual (2, props.PropertyValues.Count); props.Remove (propName); - Assert.AreEqual (1, props.PropertyValues.Length); + Assert.AreEqual (1, props.PropertyValues.Count); } [Test] @@ -139,11 +138,11 @@ namespace Spring.Objects public void AddAllInMap () { MutablePropertyValues props = new MutablePropertyValues (); - IDictionary map = new Hashtable (); - map.Add ("Name", "Fiona Apple"); + IDictionary map = new Dictionary(); + map.Add("Name", "Fiona Apple"); map.Add ("Age", 24); props.AddAll (map); - Assert.AreEqual (2, props.PropertyValues.Length); + Assert.AreEqual (2, props.PropertyValues.Count); } [Test] @@ -151,15 +150,15 @@ namespace Spring.Objects { MutablePropertyValues props = new MutablePropertyValues (); props.Add (new PropertyValue ("Name", "Fiona Apple")); - props.AddAll ((IDictionary) null); - Assert.AreEqual (1, props.PropertyValues.Length); + props.AddAll ((IDictionary) null); + Assert.AreEqual (1, props.PropertyValues.Count); } [Test] public void ChangesSince () { - IDictionary map = new Hashtable (); - PropertyValue propName = new PropertyValue ("Name", "Fiona Apple"); + IDictionary map = new Dictionary(); + PropertyValue propName = new PropertyValue("Name", "Fiona Apple"); map.Add (propName.Name, propName.Value); map.Add ("Age", 24); MutablePropertyValues props = new MutablePropertyValues (map); @@ -168,13 +167,13 @@ namespace Spring.Objects // change the name... this is the change we'll be looking for newProps.SetPropertyValueAt (new PropertyValue (propName.Name, "Naomi Woolf"), 0); IPropertyValues changes = newProps.ChangesSince (props); - Assert.AreEqual (1, changes.PropertyValues.Length); + Assert.AreEqual (1, changes.PropertyValues.Count); // the name was changed, so its the name property that should be in the changed list Assert.IsTrue (changes.Contains ("name")); newProps.Add (new PropertyValue ("Commentator", "Naomi Woolf")); changes = newProps.ChangesSince (props); - Assert.AreEqual (2, changes.PropertyValues.Length); + Assert.AreEqual (2, changes.PropertyValues.Count); // the Commentator was added, so its the Commentator property that should be in the changed list Assert.IsTrue (changes.Contains ("commentator")); // the name was changed, so its the name property that should be in the changed list @@ -184,14 +183,14 @@ namespace Spring.Objects [Test] public void ChangesSinceWithSelf () { - IDictionary map = new Hashtable (); - map.Add ("Name", "Fiona Apple"); + IDictionary map = new Dictionary(); + map.Add("Name", "Fiona Apple"); map.Add ("Age", 24); MutablePropertyValues props = new MutablePropertyValues (map); props.Remove ("name"); // get all of the changes between self and self again (there should be none); IPropertyValues changes = props.ChangesSince (props); - Assert.AreEqual (0, changes.PropertyValues.Length); + Assert.AreEqual (0, changes.PropertyValues.Count); } } } diff --git a/test/Spring/Spring.Core.Tests/Util/DefensiveEventRaiserTests.cs b/test/Spring/Spring.Core.Tests/Util/DefensiveEventRaiserTests.cs index 8d792fb6..642b2d2e 100644 --- a/test/Spring/Spring.Core.Tests/Util/DefensiveEventRaiserTests.cs +++ b/test/Spring/Spring.Core.Tests/Util/DefensiveEventRaiserTests.cs @@ -62,7 +62,7 @@ namespace Spring.Util IEventExceptionsCollector exceptions = bru.OnPop( "Iron Brew", eventRaiser ); - Assert.AreEqual(1, exceptions.Exceptions.Length); + Assert.AreEqual(1, exceptions.Exceptions.Count); Assert.IsTrue(firstCall); Assert.IsTrue(secondCall); Assert.IsTrue(thirdCall); diff --git a/test/Spring/Spring.Core.Tests/Util/ReflectionUtilsTests.cs b/test/Spring/Spring.Core.Tests/Util/ReflectionUtilsTests.cs index a9989224..350a5b45 100644 --- a/test/Spring/Spring.Core.Tests/Util/ReflectionUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Util/ReflectionUtilsTests.cs @@ -22,6 +22,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; @@ -457,8 +458,8 @@ namespace Spring.Util public void ToInterfaceArrayFromType() { Type[] expected = new Type[] { typeof(IFoo), typeof(IBar) }; - Type[] actual = ReflectionUtils.ToInterfaceArray(typeof(IBar)); - Assert.AreEqual(expected.Length, actual.Length); + IList actual = ReflectionUtils.ToInterfaceArray(typeof(IBar)); + Assert.AreEqual(expected.Length, actual.Count); Assert.AreEqual(expected[0], actual[0]); Assert.AreEqual(expected[1], actual[1]); } diff --git a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs index ce159cd4..f0a36836 100644 --- a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs @@ -21,7 +21,6 @@ #region Imports using System; -using System.Collections; using System.Collections.Generic; using NUnit.Framework; @@ -121,7 +120,7 @@ namespace Spring.Util Assert.AreEqual( ":Foo,:Bar", StringUtils.CollectionToCommaDelimitedString(arr)); - Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString(null)); + Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString(null)); } [Test] @@ -129,8 +128,8 @@ namespace Spring.Util { Foo[] arr = new Foo[] {new Foo("Foo"), new Foo("Bar")}; Assert.AreEqual( - ":Foo,:Bar", StringUtils.ArrayToCommaDelimitedString(arr)); - Assert.AreEqual("null", StringUtils.ArrayToCommaDelimitedString(null)); + ":Foo,:Bar", StringUtils.CollectionToCommaDelimitedString(arr)); + Assert.AreEqual("null", StringUtils.CollectionToCommaDelimitedString(null)); } [Test] diff --git a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs index 31c761f4..d77d56d2 100644 --- a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs +++ b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs @@ -92,14 +92,14 @@ namespace Spring.Validation get { return this.objects.Count; } } - public string[] GetObjectDefinitionNames() + public IList GetObjectDefinitionNames() { - return new List(this.objects.Keys).ToArray(); + return new List(this.objects.Keys); } - public IObjectDefinition[] GetObjectDefinitions() + public IList GetObjectDefinitions() { - return new List(this.objects.Values).ToArray(); + return new List(this.objects.Values); } public bool ContainsObjectDefinition(string name) @@ -119,7 +119,7 @@ namespace Spring.Validation this.objects[name] = definition; } - public string[] GetAliases(string name) + public IList GetAliases(string name) { throw new NotImplementedException(); } diff --git a/test/Spring/Spring.Core.Tests/Validation/ValidationNamespaceParserTests.cs b/test/Spring/Spring.Core.Tests/Validation/ValidationNamespaceParserTests.cs index dcdd82bd..44e6b242 100644 --- a/test/Spring/Spring.Core.Tests/Validation/ValidationNamespaceParserTests.cs +++ b/test/Spring/Spring.Core.Tests/Validation/ValidationNamespaceParserTests.cs @@ -20,6 +20,7 @@ #region Imports +using System.Collections.Generic; using System.IO; using System.Xml; using NUnit.Framework; @@ -64,8 +65,8 @@ namespace Spring.Validation parser.ParseElement(element, parserContext); } } - IObjectDefinition[] defs = registry.GetObjectDefinitions(); - Assert.AreEqual(9, defs.Length); + IList defs = registry.GetObjectDefinitions(); + Assert.AreEqual(9, defs.Count); IObjectDefinition def = registry.GetObjectDefinition("destinationAirportValidator"); Assert.IsTrue(def.IsSingleton); diff --git a/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs b/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs index 5263ac65..1a35bbb0 100644 --- a/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs +++ b/test/Spring/Spring.Data.Tests/Data/Common/DbProviderFactoryTests.cs @@ -19,6 +19,7 @@ #endregion using System; +using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Threading; @@ -217,8 +218,8 @@ namespace Spring.Data.Common //Initialize internal application context. factory DbProviderFactory.GetDbProvider("SqlServer-2.0"); IApplicationContext ctx = DbProviderFactory.ApplicationContext; - string[] dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider)); - Assert.IsTrue(dbProviderNames.Length > 0); + IList dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider)); + Assert.IsTrue(dbProviderNames.Count > 0); } diff --git a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs index dd737519..ce0f5043 100644 --- a/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs +++ b/test/Spring/Spring.Messaging.Nms.Tests/Messaging/Nms/Config/NmsNamespaceHandlerTests.cs @@ -73,14 +73,14 @@ namespace Spring.Messaging.Nms.Config [Test] public void ObjectsCreated() { - IDictionary containers = ctx.GetObjectsOfType(); + IDictionary containers = ctx.GetObjects(); Assert.AreEqual(3, containers.Count); } [Test] public void ContainerConfiguration() { - IDictionary containers = ctx.GetObjectsOfType(); + IDictionary containers = ctx.GetObjects(); IConnectionFactory defaultConnectionFactory = (IConnectionFactory) ctx.GetObject(DEFAULT_CONNECTION_FACTORY); IConnectionFactory explicitConnectionFactory = (IConnectionFactory) ctx.GetObject(EXPLICIT_CONNECTION_FACTORY); diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/Adapter/StandardReflectionMessageListenerAdapter.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/Adapter/StandardReflectionMessageListenerAdapter.cs index 7fe63a4c..8dbe64de 100644 --- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/Adapter/StandardReflectionMessageListenerAdapter.cs +++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/Adapter/StandardReflectionMessageListenerAdapter.cs @@ -49,7 +49,7 @@ namespace Spring.Messaging.Listener.Adapter { throw new ListenerExecutionFailedException("Failed to invoke the target method '" + methodName + "' with arguments " + - StringUtils.ArrayToCommaDelimitedString(arguments)); + StringUtils.CollectionToCommaDelimitedString(arguments)); } try { @@ -62,7 +62,7 @@ namespace Spring.Messaging.Listener.Adapter { throw new ListenerExecutionFailedException("Failed to invoke the target method '" + methodName + "' with arguments " + - StringUtils.ArrayToCommaDelimitedString(arguments), e); + StringUtils.CollectionToCommaDelimitedString(arguments), e); } } } diff --git a/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs b/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs index ac1a5224..a16c82bf 100644 --- a/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs +++ b/test/Spring/Spring.Services.Tests/ServiceModel/Config/ChannelFactoryObjectDefinitionParserTests.cs @@ -104,7 +104,7 @@ namespace Spring.ServiceModel.Config IApplicationContext ctx = new XmlApplicationContext( ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.WithoutId.xml", this.GetType())); - IDictionary channels = ctx.GetObjectsOfType(); + IDictionary channels = ctx.GetObjects(); Assert.AreEqual(1, channels.Count); } diff --git a/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionFactoryTests.cs b/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionFactoryTests.cs index a71b3735..bbbf4413 100644 --- a/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionFactoryTests.cs +++ b/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionFactoryTests.cs @@ -50,7 +50,7 @@ namespace Spring.Objects.Factory.Support typeof(TestObject).FullName, null, AppDomain.CurrentDomain); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof(TestObject), definition.ObjectType); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in."); @@ -65,7 +65,7 @@ namespace Spring.Objects.Factory.Support typeof(TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof(TestObject), definition.ObjectType); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in."); @@ -80,7 +80,7 @@ namespace Spring.Objects.Factory.Support typeof(TestObject).FullName, null, null); Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so)."); Assert.AreEqual(typeof(TestObject).FullName, definition.ObjectTypeName); - Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length, + Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count, "Must not have any property values as none were passed in."); Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount, "Must not have any ctor args as none were passed in.");