diff --git a/src/Spring/Spring.Web.Mvc3/Context/Support/MvcApplicationContext.cs b/src/Spring/Spring.Web.Mvc3/Context/Support/MvcApplicationContext.cs index bfb6cf4b..fdb34f71 100644 --- a/src/Spring/Spring.Web.Mvc3/Context/Support/MvcApplicationContext.cs +++ b/src/Spring/Spring.Web.Mvc3/Context/Support/MvcApplicationContext.cs @@ -76,7 +76,7 @@ namespace Spring.Context.Support if (log.IsDebugEnabled) { - log.Debug("created instance " + this.ToString()); + log.Debug("created instance " + this); } } diff --git a/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs b/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs index 802d90d8..67f6e8d4 100644 --- a/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs +++ b/src/Spring/Spring.Web.Mvc3/SpringMvcDependencyResolver.cs @@ -8,18 +8,20 @@ using Spring.Context.Support; namespace Spring.Web.Mvc { /// - /// Spring-based implementation of the interface. + /// Spring-based implementation of the interface for ASP.NET MVC. /// public class SpringMvcDependencyResolver : IDependencyResolver { private static readonly string IgnoreViewNamespace = "ASP."; - + /// + /// The to be used by the resolver + /// private IApplicationContext _context; /// /// Initializes a new instance of the class. /// - /// The context. + /// The to be used by the resolver public SpringMvcDependencyResolver(IApplicationContext context) { _context = context; @@ -48,6 +50,7 @@ namespace Spring.Web.Mvc return _context; } + protected set { _context = value; } } /// @@ -57,7 +60,7 @@ namespace Spring.Web.Mvc /// Defaults to using the root (default) Application Context. /// /// The name of the application context. - public static string ApplicationContextName { get; set; } + public string ApplicationContextName { get; set; } /// diff --git a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContext.cs b/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContext.cs deleted file mode 100644 index 2543c481..00000000 --- a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContext.cs +++ /dev/null @@ -1,148 +0,0 @@ -#region License - -/* - * Copyright © 2002-2011 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.Linq; -using System.Text; -using Spring.Context.Support; -using Spring.Core.IO; - -namespace Spring.Context.Support -{ - /// - /// Application Context for ASP.NET MVC Applications - /// - public class MvcApplicationContext : AbstractXmlApplicationContext - { - private readonly string[] _configurationLocations; - - private readonly IResource[] _configurationResources; - - /// - /// Create a new MvcApplicationContext, loading the definitions - /// from the given XML resource. - /// - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// Names of configuration resources. - public MvcApplicationContext(string name, bool caseSensitive, params string[] configurationLocations) - : this(new MvcApplicationContextArgs(name, null, configurationLocations, null, caseSensitive)) - { - } - - /// - /// Create a new MvcApplicationContext with the given parent, - /// loading the definitions from the given XML resources. - /// - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// The parent context. - /// Names of configuration resources. - public MvcApplicationContext(string name, bool caseSensitive, IApplicationContext parentContext, - params string[] configurationLocations) - : this(new MvcApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive)) - { } - - /// - /// Initializes a new instance of the class. - /// - /// The args. - public MvcApplicationContext(MvcApplicationContextArgs args) - : base(args.Name, args.CaseSensitive, args.ParentContext) - { - _configurationLocations = args.ConfigurationLocations; - _configurationResources = args.ConfigurationResources; - - Refresh(); - - if (log.IsDebugEnabled) - { - log.Debug("created instance " + this); - } - } - - /// - /// Create a new MvcApplicationContext, loading the definitions - /// from the given XML resource. - /// - /// The application context name. - /// Flag specifying whether to make this context case sensitive or not. - /// Names of configuration resources. - /// Configuration resources. - public MvcApplicationContext(string name, bool caseSensitive, string[] configurationLocations, IResource[] configurationResources) - : this(new MvcApplicationContextArgs(name, null, configurationLocations, configurationResources, caseSensitive)) - { - } - - /// - /// Create a new MvcApplicationContext, loading the definitions - /// from the given XML resource. - /// - /// Names of configuration resources. - public MvcApplicationContext(params string[] configurationLocations) - : this(new MvcApplicationContextArgs(string.Empty, null, configurationLocations, null, false)) - { - } - - /// - /// An array of resource locations, referring to the XML object - /// definition files that this context is to be built with. - /// - /// - /// - ///

- /// Examples of the format of the various strings that would be - /// returned by accessing this property can be found in the overview - /// documentation of with the - /// class. - ///

- ///
- /// - /// An array of resource locations, or if none. - /// - protected override string[] ConfigurationLocations - { - get { return _configurationLocations; } - } - - /// - /// An array of resources that this context is to be built with. - /// - /// - /// - ///

- /// Examples of the format of the various strings that would be - /// returned by accessing this property can be found in the overview - /// documentation of with the - /// class. - ///

- ///
- /// - /// An array of s, or if none. - /// - protected override IResource[] ConfigurationResources - { - get { return _configurationResources; } - } - - } -} diff --git a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContextArgs.cs b/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContextArgs.cs deleted file mode 100644 index fdeddfce..00000000 --- a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcApplicationContextArgs.cs +++ /dev/null @@ -1,76 +0,0 @@ -#region License - -/* - * Copyright © 2002-2011 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 Spring.Core.IO; - -namespace Spring.Context.Support -{ - /// - /// Encapsulates arguments to the class. - /// - public class MvcApplicationContextArgs : AbstractXmlApplicationContextArgs - { - - private const bool DEFAULT_CASESENSITIVE = false; - private const bool DEFAULT_REFRESH = false; - - /// - /// Initializes a new instance of the MvcApplicationContextArgs class. - /// - public MvcApplicationContextArgs() - { - CaseSensitive = DEFAULT_CASESENSITIVE; - } - - /// - /// Initializes a new instance of the MvcApplicationContextArgs class. - /// - /// The name. - /// The parent context. - /// The configuration locations. - /// The configuration resources. - public MvcApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources) - : this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE) - { } - - - /// - /// Initializes a new instance of the MvcApplicationContextArgs class. - /// - /// The name. - /// The parent context. - /// The configuration locations. - /// The configuration resources. - /// if set to true [case sensitive]. - public MvcApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources, bool caseSensitive) - { - Name = name; - ParentContext = parentContext; - ConfigurationLocations = configurationLocations; - ConfigurationResources = configurationResources; - CaseSensitive = caseSensitive; - Refresh = DEFAULT_REFRESH; - } - - - } -} diff --git a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcContextHandler.cs b/src/Spring/Spring.Web.Mvc4/Context/Support/MvcContextHandler.cs deleted file mode 100644 index 35663aba..00000000 --- a/src/Spring/Spring.Web.Mvc4/Context/Support/MvcContextHandler.cs +++ /dev/null @@ -1,36 +0,0 @@ -#region License - -/* - * Copyright © 2002-2011 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.Linq; -using System.Text; -using Spring.Context.Support; - -namespace Spring.Context.Support -{ - /// - /// Context Handler for ASP.NET MVC Applications - /// - public class MvcContextHandler : WebContextHandler - { - - } -} diff --git a/src/Spring/Spring.Web.Mvc4/Spring.Web.Mvc4.2010.csproj b/src/Spring/Spring.Web.Mvc4/Spring.Web.Mvc4.2010.csproj index f55f37a6..a1a220ae 100644 --- a/src/Spring/Spring.Web.Mvc4/Spring.Web.Mvc4.2010.csproj +++ b/src/Spring/Spring.Web.Mvc4/Spring.Web.Mvc4.2010.csproj @@ -103,10 +103,18 @@ CommonAssemblyInfo.cs - - - - + + Context\Support\MvcApplicationContext.cs + + + Context\Support\MvcApplicationContextArgs.cs + + + Context\Support\MvcContextHandler.cs + + + SpringMvcDependencyResolver.cs + diff --git a/src/Spring/Spring.Web.Mvc4/SpringMvcDependencyResolver.cs b/src/Spring/Spring.Web.Mvc4/SpringMvcDependencyResolver.cs deleted file mode 100644 index 2134fcc0..00000000 --- a/src/Spring/Spring.Web.Mvc4/SpringMvcDependencyResolver.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Mvc; -using Spring.Context; -using Spring.Context.Support; - -namespace Spring.Web.Mvc -{ - /// - /// Spring-based implementation of the interface for ASP.NET MVC. - /// - public class SpringMvcDependencyResolver : IDependencyResolver - { - private static readonly string IgnoreViewNamespace = "ASP."; - /// - /// The to be used by the resolver - /// - private IApplicationContext _context; - - /// - /// Initializes a new instance of the class. - /// - /// The to be used by the resolver - public SpringMvcDependencyResolver(IApplicationContext context) - { - _context = context; - } - - - /// - /// Gets the application context. - /// - /// The application context. - public IApplicationContext ApplicationContext - { - get - { - if (_context == null || _context.Name != ApplicationContextName) - { - if (string.IsNullOrEmpty(ApplicationContextName)) - { - _context = ContextRegistry.GetContext(); - } - else - { - _context = ContextRegistry.GetContext(ApplicationContextName); - } - } - - return _context; - } - protected set { _context = value; } - } - - /// - /// Gets or sets the name of the application context. - /// - /// - /// Defaults to using the root (default) Application Context. - /// - /// The name of the application context. - public string ApplicationContextName { get; set; } - - - /// - /// Resolves singly registered services that support arbitrary object creation. - /// - /// The type of the requested service or object. - /// The requested service or object. - public object GetService(Type serviceType) - { - object service = null; - - if (serviceType != null && !serviceType.FullName.StartsWith(IgnoreViewNamespace)) - { - var services = ApplicationContext.GetObjectsOfType(serviceType); - if (services.Count > 0) - { - service = services.First().Value; - } - } - - return service; - } - - /// - /// Resolves multiply registered services. - /// - /// The type of the requested services. - /// The requested services. - public IEnumerable GetServices(Type serviceType) - { - var services = ApplicationContext.GetObjectsOfType(serviceType); - return services.Values; - } - } -} diff --git a/src/Spring/Spring.Web.Mvc5/Spring.Web.Mvc5.2010.csproj b/src/Spring/Spring.Web.Mvc5/Spring.Web.Mvc5.2010.csproj index fb14a721..aefedd90 100644 --- a/src/Spring/Spring.Web.Mvc5/Spring.Web.Mvc5.2010.csproj +++ b/src/Spring/Spring.Web.Mvc5/Spring.Web.Mvc5.2010.csproj @@ -103,21 +103,21 @@ CommonAssemblyInfo.cs - + Context\Support\MvcApplicationContext.cs - + Context\Support\MvcApplicationContextArgs.cs - + Context\Support\MvcContextHandler.cs + + SpringMvcDependencyResolver.cs + SpringMvcApplication.cs - - SpringMvcDependencyResolver.cs - SpringWebApiDependencyResolver.cs