Fix remaining issues that were spotted by build and test system

This commit is contained in:
Marko Lahma
2012-03-24 13:29:11 +02:00
parent f498ba2264
commit 68b67e3f45
8 changed files with 41 additions and 34 deletions

View File

@@ -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<string, ICommand> commands = ctx.GetObjectsOfType<ICommand>();
foreach (ICommand command in commands.Values)
{

View File

@@ -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<string, IAccountManager> dict = context.GetObjectsOfType<IAccountManager>();
accountManager = context["accountManager"] as IAccountManager;
CleanDb(context);
}

View File

@@ -1444,7 +1444,7 @@ namespace Spring.Context.Support
/// </exception>
public IDictionary<string, T> GetObjectsOfType<T>()
{
return (IDictionary<string, T>) GetObjectsOfType(typeof(T));
return ObjectFactory.GetObjectsOfType<T>(true, true);
}
/// <summary>

View File

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

View File

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

View File

@@ -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
/// </exception>
public IDictionary<string, T> GetObjectsOfType<T>()
{
return (IDictionary<string, T>) GetObjectsOfType(typeof(T));
Dictionary<string, T> collector = new Dictionary<string, T>();
DoGetObjectsOfType(typeof(T), true, true, collector);
return collector;
}
/// <summary>
@@ -847,9 +850,15 @@ namespace Spring.Objects.Factory.Support
/// If the objects could not be created.
/// </exception>
public IDictionary<string, object> GetObjectsOfType(Type type, bool includePrototypes, bool includeFactoryObjects)
{
Dictionary<string, object> collector = new Dictionary<string, object>();
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<string, object> matches = new Dictionary<string, object>();
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;
}
/// <summary>
@@ -911,7 +919,9 @@ namespace Spring.Objects.Factory.Support
/// </exception>
public IDictionary<string, T> GetObjectsOfType<T>(bool includePrototypes, bool includeFactoryObjects)
{
return (IDictionary<string, T>) GetObjectsOfType(typeof(T), includePrototypes, includeFactoryObjects);
Dictionary<string, T> collector = new Dictionary<string, T>();
DoGetObjectsOfType(typeof(T), includeFactoryObjects, includePrototypes, collector);
return collector;
}
/// <summary>

View File

@@ -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<DictionaryEntry>().First().Value;
controller = (IController)controllers.First().Value;
}
}

View File

@@ -74,7 +74,7 @@ namespace Spring.Web.Mvc
var services = ApplicationContext.GetObjectsOfType(serviceType);
if (services.Count > 0)
{
service = services.Cast<DictionaryEntry>().First().Value;
service = services.First().Value;
}
}
@@ -89,7 +89,7 @@ namespace Spring.Web.Mvc
public IEnumerable<object> GetServices(Type serviceType)
{
var services = ApplicationContext.GetObjectsOfType(serviceType);
return services.Values.Cast<object>();
return services.Values;
}
}
}