remove unnecessary source duplication in MVC Source and replace with source file LINKs
This commit is contained in:
@@ -76,7 +76,7 @@ namespace Spring.Context.Support
|
||||
|
||||
if (log.IsDebugEnabled)
|
||||
{
|
||||
log.Debug("created instance " + this.ToString());
|
||||
log.Debug("created instance " + this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,18 +8,20 @@ using Spring.Context.Support;
|
||||
namespace Spring.Web.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Spring-based implementation of the <see cref="IDependencyResolver"/> interface.
|
||||
/// Spring-based implementation of the <see cref="IDependencyResolver"/> interface for ASP.NET MVC.
|
||||
/// </summary>
|
||||
public class SpringMvcDependencyResolver : IDependencyResolver
|
||||
{
|
||||
private static readonly string IgnoreViewNamespace = "ASP.";
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IApplicationContext"/> to be used by the resolver
|
||||
/// </summary>
|
||||
private IApplicationContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpringMvcDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
/// <param name="context">The <see cref="IApplicationContext"/> to be used by the resolver</param>
|
||||
public SpringMvcDependencyResolver(IApplicationContext context)
|
||||
{
|
||||
_context = context;
|
||||
@@ -48,6 +50,7 @@ namespace Spring.Web.Mvc
|
||||
|
||||
return _context;
|
||||
}
|
||||
protected set { _context = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,7 +60,7 @@ namespace Spring.Web.Mvc
|
||||
/// Defaults to using the root (default) Application Context.
|
||||
/// </remarks>
|
||||
/// <value>The name of the application context.</value>
|
||||
public static string ApplicationContextName { get; set; }
|
||||
public string ApplicationContextName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Application Context for ASP.NET MVC Applications
|
||||
/// </summary>
|
||||
public class MvcApplicationContext : AbstractXmlApplicationContext
|
||||
{
|
||||
private readonly string[] _configurationLocations;
|
||||
|
||||
private readonly IResource[] _configurationResources;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new MvcApplicationContext, loading the definitions
|
||||
/// from the given XML resource.
|
||||
/// </summary>
|
||||
/// <param name="name">The application context name.</param>
|
||||
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
/// <param name="configurationLocations">Names of configuration resources.</param>
|
||||
public MvcApplicationContext(string name, bool caseSensitive, params string[] configurationLocations)
|
||||
: this(new MvcApplicationContextArgs(name, null, configurationLocations, null, caseSensitive))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new MvcApplicationContext with the given parent,
|
||||
/// loading the definitions from the given XML resources.
|
||||
/// </summary>
|
||||
/// <param name="name">The application context name.</param>
|
||||
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
/// <param name="parentContext">The parent context.</param>
|
||||
/// <param name="configurationLocations">Names of configuration resources.</param>
|
||||
public MvcApplicationContext(string name, bool caseSensitive, IApplicationContext parentContext,
|
||||
params string[] configurationLocations)
|
||||
: this(new MvcApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive))
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MvcApplicationContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new MvcApplicationContext, loading the definitions
|
||||
/// from the given XML resource.
|
||||
/// </summary>
|
||||
/// <param name="name">The application context name.</param>
|
||||
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
/// <param name="configurationLocations">Names of configuration resources.</param>
|
||||
/// <param name="configurationResources">Configuration resources.</param>
|
||||
public MvcApplicationContext(string name, bool caseSensitive, string[] configurationLocations, IResource[] configurationResources)
|
||||
: this(new MvcApplicationContextArgs(name, null, configurationLocations, configurationResources, caseSensitive))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new MvcApplicationContext, loading the definitions
|
||||
/// from the given XML resource.
|
||||
/// </summary>
|
||||
/// <param name="configurationLocations">Names of configuration resources.</param>
|
||||
public MvcApplicationContext(params string[] configurationLocations)
|
||||
: this(new MvcApplicationContextArgs(string.Empty, null, configurationLocations, null, false))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An array of resource locations, referring to the XML object
|
||||
/// definition files that this context is to be built with.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <remarks>
|
||||
/// <p>
|
||||
/// 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 <see cref="XmlApplicationContext"/>
|
||||
/// class.
|
||||
/// </p>
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// An array of resource locations, or <see langword="null"/> if none.
|
||||
/// </returns>
|
||||
protected override string[] ConfigurationLocations
|
||||
{
|
||||
get { return _configurationLocations; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An array of resources that this context is to be built with.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <remarks>
|
||||
/// <p>
|
||||
/// 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 <see cref="XmlApplicationContext"/>
|
||||
/// class.
|
||||
/// </p>
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// An array of <see cref="Spring.Core.IO.IResource"/>s, or <see langword="null"/> if none.
|
||||
/// </returns>
|
||||
protected override IResource[] ConfigurationResources
|
||||
{
|
||||
get { return _configurationResources; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates arguments to the <see cref="Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
/// </summary>
|
||||
public class MvcApplicationContextArgs : AbstractXmlApplicationContextArgs
|
||||
{
|
||||
|
||||
private const bool DEFAULT_CASESENSITIVE = false;
|
||||
private const bool DEFAULT_REFRESH = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
/// </summary>
|
||||
public MvcApplicationContextArgs()
|
||||
{
|
||||
CaseSensitive = DEFAULT_CASESENSITIVE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="parentContext">The parent context.</param>
|
||||
/// <param name="configurationLocations">The configuration locations.</param>
|
||||
/// <param name="configurationResources">The configuration resources.</param>
|
||||
public MvcApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
|
||||
: this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE)
|
||||
{ }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="parentContext">The parent context.</param>
|
||||
/// <param name="configurationLocations">The configuration locations.</param>
|
||||
/// <param name="configurationResources">The configuration resources.</param>
|
||||
/// <param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Context Handler for ASP.NET MVC Applications
|
||||
/// </summary>
|
||||
public class MvcContextHandler : WebContextHandler
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -103,10 +103,18 @@
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Context\Support\MvcApplicationContext.cs" />
|
||||
<Compile Include="Context\Support\MvcApplicationContextArgs.cs" />
|
||||
<Compile Include="Context\Support\MvcContextHandler.cs" />
|
||||
<Compile Include="SpringMvcDependencyResolver.cs" />
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcApplicationContext.cs">
|
||||
<Link>Context\Support\MvcApplicationContext.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcApplicationContextArgs.cs">
|
||||
<Link>Context\Support\MvcApplicationContextArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcContextHandler.cs">
|
||||
<Link>Context\Support\MvcContextHandler.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc3\SpringMvcDependencyResolver.cs">
|
||||
<Link>SpringMvcDependencyResolver.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="SpringMvcApplication.cs" />
|
||||
<Compile Include="SpringWebApiDependencyResolver.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Spring-based implementation of the <see cref="IDependencyResolver"/> interface for ASP.NET MVC.
|
||||
/// </summary>
|
||||
public class SpringMvcDependencyResolver : IDependencyResolver
|
||||
{
|
||||
private static readonly string IgnoreViewNamespace = "ASP.";
|
||||
/// <summary>
|
||||
/// The <see cref="IApplicationContext"/> to be used by the resolver
|
||||
/// </summary>
|
||||
private IApplicationContext _context;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpringMvcDependencyResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="IApplicationContext"/> to be used by the resolver</param>
|
||||
public SpringMvcDependencyResolver(IApplicationContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application context.
|
||||
/// </summary>
|
||||
/// <value>The application context.</value>
|
||||
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; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the application context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Defaults to using the root (default) Application Context.
|
||||
/// </remarks>
|
||||
/// <value>The name of the application context.</value>
|
||||
public string ApplicationContextName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves singly registered services that support arbitrary object creation.
|
||||
/// </summary>
|
||||
/// <param name="serviceType">The type of the requested service or object.</param>
|
||||
/// <returns>The requested service or object.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves multiply registered services.
|
||||
/// </summary>
|
||||
/// <param name="serviceType">The type of the requested services.</param>
|
||||
/// <returns>The requested services.</returns>
|
||||
public IEnumerable<object> GetServices(Type serviceType)
|
||||
{
|
||||
var services = ApplicationContext.GetObjectsOfType(serviceType);
|
||||
return services.Values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,21 +103,21 @@
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\Context\Support\MvcApplicationContext.cs">
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcApplicationContext.cs">
|
||||
<Link>Context\Support\MvcApplicationContext.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\Context\Support\MvcApplicationContextArgs.cs">
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcApplicationContextArgs.cs">
|
||||
<Link>Context\Support\MvcApplicationContextArgs.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\Context\Support\MvcContextHandler.cs">
|
||||
<Compile Include="..\Spring.Web.Mvc3\Context\Support\MvcContextHandler.cs">
|
||||
<Link>Context\Support\MvcContextHandler.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc3\SpringMvcDependencyResolver.cs">
|
||||
<Link>SpringMvcDependencyResolver.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\SpringMvcApplication.cs">
|
||||
<Link>SpringMvcApplication.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\SpringMvcDependencyResolver.cs">
|
||||
<Link>SpringMvcDependencyResolver.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Spring.Web.Mvc4\SpringWebApiDependencyResolver.cs">
|
||||
<Link>SpringWebApiDependencyResolver.cs</Link>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user