Rename IControllerAssemblyProvider to IAssemblyProvider and follow through resultant renames

This commit is contained in:
YishaiGalatzer 2014-10-11 13:26:07 -07:00
parent 7fabb80991
commit 13ee27c92c
17 changed files with 34 additions and 34 deletions

View File

@ -41,7 +41,7 @@ namespace MvcSample.Web
// Setup services with a test AssemblyProvider so that only the // Setup services with a test AssemblyProvider so that only the
// sample's assemblies are loaded. This prevents loading controllers from other assemblies // sample's assemblies are loaded. This prevents loading controllers from other assemblies
// when the sample is used in the Functional Tests. // when the sample is used in the Functional Tests.
services.AddTransient<IControllerAssemblyProvider, TestAssemblyProvider<Startup>>(); services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
services.ConfigureOptions<MvcOptions>(options => services.ConfigureOptions<MvcOptions>(options =>
{ {
options.Filters.Add(typeof(PassThroughAttribute), order: 17); options.Filters.Add(typeof(PassThroughAttribute), order: 17);
@ -81,7 +81,7 @@ namespace MvcSample.Web
// Setup services with a test AssemblyProvider so that only the // Setup services with a test AssemblyProvider so that only the
// sample's assemblies are loaded. This prevents loading controllers from other assemblies // sample's assemblies are loaded. This prevents loading controllers from other assemblies
// when the sample is used in the Functional Tests. // when the sample is used in the Functional Tests.
services.AddTransient<IControllerAssemblyProvider, TestAssemblyProvider<Startup>>(); services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
services.ConfigureOptions<MvcOptions>(options => services.ConfigureOptions<MvcOptions>(options =>
{ {

View File

@ -17,7 +17,7 @@ namespace MvcSample.Web
/// This is a generic type because it needs to instantiated by a service provider to replace /// This is a generic type because it needs to instantiated by a service provider to replace
/// a built-in MVC service. /// a built-in MVC service.
/// </remarks> /// </remarks>
public class TestAssemblyProvider<T> : IControllerAssemblyProvider public class TestAssemblyProvider<T> : IAssemblyProvider
{ {
public TestAssemblyProvider() public TestAssemblyProvider()
{ {

View File

@ -21,17 +21,17 @@ namespace Microsoft.AspNet.Mvc
// the reflected model is null. // the reflected model is null.
private const int DefaultAttributeRouteOrder = 0; private const int DefaultAttributeRouteOrder = 0;
private readonly IControllerAssemblyProvider _controllerAssemblyProvider; private readonly IAssemblyProvider _assemblyProvider;
private readonly IActionDiscoveryConventions _conventions; private readonly IActionDiscoveryConventions _conventions;
private readonly IReadOnlyList<IFilter> _globalFilters; private readonly IReadOnlyList<IFilter> _globalFilters;
private readonly IEnumerable<IGlobalModelConvention> _modelConventions; private readonly IEnumerable<IGlobalModelConvention> _modelConventions;
public ControllerActionDescriptorProvider(IControllerAssemblyProvider controllerAssemblyProvider, public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider,
IActionDiscoveryConventions conventions, IActionDiscoveryConventions conventions,
IGlobalFilterProvider globalFilters, IGlobalFilterProvider globalFilters,
IOptionsAccessor<MvcOptions> optionsAccessor) IOptionsAccessor<MvcOptions> optionsAccessor)
{ {
_controllerAssemblyProvider = controllerAssemblyProvider; _assemblyProvider = assemblyProvider;
_conventions = conventions; _conventions = conventions;
_globalFilters = globalFilters.Filters; _globalFilters = globalFilters.Filters;
_modelConventions = optionsAccessor.Options.ApplicationModelConventions; _modelConventions = optionsAccessor.Options.ApplicationModelConventions;
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc
var applicationModel = new GlobalModel(); var applicationModel = new GlobalModel();
applicationModel.Filters.AddRange(_globalFilters); applicationModel.Filters.AddRange(_globalFilters);
var assemblies = _controllerAssemblyProvider.CandidateAssemblies; var assemblies = _assemblyProvider.CandidateAssemblies;
var types = assemblies.SelectMany(a => a.DefinedTypes); var types = assemblies.SelectMany(a => a.DefinedTypes);
var controllerTypes = types.Where(_conventions.IsController); var controllerTypes = types.Where(_conventions.IsController);

View File

@ -9,7 +9,7 @@ using Microsoft.Framework.Runtime;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public class DefaultControllerAssemblyProvider : IControllerAssemblyProvider public class DefaultAssemblyProvider : IAssemblyProvider
{ {
// List of Mvc assemblies that we'll use as roots for controller discovery. // List of Mvc assemblies that we'll use as roots for controller discovery.
private static readonly HashSet<string> _mvcAssemblyList = new HashSet<string>(StringComparer.Ordinal) private static readonly HashSet<string> _mvcAssemblyList = new HashSet<string>(StringComparer.Ordinal)
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Mvc
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
public DefaultControllerAssemblyProvider(ILibraryManager libraryManager) public DefaultAssemblyProvider(ILibraryManager libraryManager)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;
} }

View File

@ -6,7 +6,7 @@ using System.Reflection;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public interface IControllerAssemblyProvider public interface IAssemblyProvider
{ {
IEnumerable<Assembly> CandidateAssemblies { get; } IEnumerable<Assembly> CandidateAssemblies { get; }
} }

View File

@ -9,9 +9,9 @@ namespace Microsoft.AspNet.Mvc
{ {
public class DefaultViewComponentSelector : IViewComponentSelector public class DefaultViewComponentSelector : IViewComponentSelector
{ {
private readonly IControllerAssemblyProvider _assemblyProvider; private readonly IAssemblyProvider _assemblyProvider;
public DefaultViewComponentSelector(IControllerAssemblyProvider assemblyProvider) public DefaultViewComponentSelector(IAssemblyProvider assemblyProvider)
{ {
_assemblyProvider = assemblyProvider; _assemblyProvider = assemblyProvider;
} }

View File

@ -37,12 +37,12 @@ namespace Microsoft.AspNet.Mvc.Razor
private readonly IMvcRazorHost _razorHost; private readonly IMvcRazorHost _razorHost;
public RazorCompilationService(IServiceProvider serviceProvider, public RazorCompilationService(IServiceProvider serviceProvider,
IControllerAssemblyProvider _controllerAssemblyProvider, IAssemblyProvider _assemblyProvider,
IMvcRazorHost razorHost) IMvcRazorHost razorHost)
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
_razorHost = razorHost; _razorHost = razorHost;
_cache = new CompilerCache(_controllerAssemblyProvider.CandidateAssemblies); _cache = new CompilerCache(_assemblyProvider.CandidateAssemblies);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc
DefaultActionConstraintProvider>(); DefaultActionConstraintProvider>();
yield return describe.Transient<IActionInvokerFactory, ActionInvokerFactory>(); yield return describe.Transient<IActionInvokerFactory, ActionInvokerFactory>();
yield return describe.Transient<IControllerAssemblyProvider, DefaultControllerAssemblyProvider>(); yield return describe.Transient<IAssemblyProvider, DefaultAssemblyProvider>();
yield return describe.Transient<IActionDiscoveryConventions, DefaultActionDiscoveryConventions>(); yield return describe.Transient<IActionDiscoveryConventions, DefaultActionDiscoveryConventions>();
// The host is designed to be discarded after consumption and is very inexpensive to initialize. // The host is designed to be discarded after consumption and is very inexpensive to initialize.

View File

@ -196,7 +196,7 @@ namespace Microsoft.AspNet.Mvc
private ControllerActionDescriptorProvider GetActionDescriptorProvider( private ControllerActionDescriptorProvider GetActionDescriptorProvider(
IActionDiscoveryConventions actionDiscoveryConventions = null) IActionDiscoveryConventions actionDiscoveryConventions = null)
{ {
var controllerAssemblyProvider = new StaticControllerAssemblyProvider(); var assemblyProvider = new StaticAssemblyProvider();
if (actionDiscoveryConventions == null) if (actionDiscoveryConventions == null)
{ {
@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Mvc
} }
return new ControllerActionDescriptorProvider( return new ControllerActionDescriptorProvider(
controllerAssemblyProvider, assemblyProvider,
actionDiscoveryConventions, actionDiscoveryConventions,
new TestGlobalFilterProvider(), new TestGlobalFilterProvider(),
new MockMvcOptionsAccessor()); new MockMvcOptionsAccessor());

View File

@ -1334,7 +1334,7 @@ namespace Microsoft.AspNet.Mvc.Test
{ {
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo); var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo);
var assemblyProvider = new Mock<IControllerAssemblyProvider>(); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider assemblyProvider
.SetupGet(ap => ap.CandidateAssemblies) .SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { controllerTypeInfo.Assembly }); .Returns(new Assembly[] { controllerTypeInfo.Assembly });
@ -1353,7 +1353,7 @@ namespace Microsoft.AspNet.Mvc.Test
{ {
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo); var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo);
var assemblyProvider = new Mock<IControllerAssemblyProvider>(); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider assemblyProvider
.SetupGet(ap => ap.CandidateAssemblies) .SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { controllerTypeInfo.First().Assembly }); .Returns(new Assembly[] { controllerTypeInfo.First().Assembly });
@ -1373,7 +1373,7 @@ namespace Microsoft.AspNet.Mvc.Test
{ {
var conventions = new StaticActionDiscoveryConventions(type); var conventions = new StaticActionDiscoveryConventions(type);
var assemblyProvider = new Mock<IControllerAssemblyProvider>(); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider assemblyProvider
.SetupGet(ap => ap.CandidateAssemblies) .SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { type.Assembly }); .Returns(new Assembly[] { type.Assembly });
@ -1389,7 +1389,7 @@ namespace Microsoft.AspNet.Mvc.Test
{ {
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfos); var conventions = new StaticActionDiscoveryConventions(controllerTypeInfos);
var assemblyProvider = new Mock<IControllerAssemblyProvider>(); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider assemblyProvider
.SetupGet(ap => ap.CandidateAssemblies) .SetupGet(ap => ap.CandidateAssemblies)
.Returns(controllerTypeInfos.Select(cti => cti.Assembly).Distinct()); .Returns(controllerTypeInfos.Select(cti => cti.Assembly).Distinct());

View File

@ -100,10 +100,10 @@ namespace Microsoft.AspNet.Mvc
private ControllerActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions) private ControllerActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions)
{ {
var assemblies = new Assembly[] { typeof(DefaultActionDiscoveryConventionsActionSelectionTests).GetTypeInfo().Assembly, }; var assemblies = new Assembly[] { typeof(DefaultActionDiscoveryConventionsActionSelectionTests).GetTypeInfo().Assembly, };
var controllerAssemblyProvider = new Mock<IControllerAssemblyProvider>(); var AssemblyProvider = new Mock<IAssemblyProvider>();
controllerAssemblyProvider.SetupGet(x => x.CandidateAssemblies).Returns(assemblies); AssemblyProvider.SetupGet(x => x.CandidateAssemblies).Returns(assemblies);
return new ControllerActionDescriptorProvider( return new ControllerActionDescriptorProvider(
controllerAssemblyProvider.Object, AssemblyProvider.Object,
actionDiscoveryConventions, actionDiscoveryConventions,
new TestGlobalFilterProvider(), new TestGlobalFilterProvider(),
new MockMvcOptionsAccessor()); new MockMvcOptionsAccessor());

View File

@ -11,7 +11,7 @@ using Xunit;
namespace Microsoft.AspNet.Mvc.Core namespace Microsoft.AspNet.Mvc.Core
{ {
public class DefaultControllerAssemblyProviderTests public class DefaultAssemblyProviderTests
{ {
[Fact] [Fact]
public void CandidateAssemblies_IgnoresMvcAssemblies() public void CandidateAssemblies_IgnoresMvcAssemblies()
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Core
CreateLibraryInfo("SomeRandomAssembly"), CreateLibraryInfo("SomeRandomAssembly"),
}) })
.Verifiable(); .Verifiable();
var provider = new DefaultControllerAssemblyProvider(manager.Object); var provider = new DefaultAssemblyProvider(manager.Object);
// Act // Act
var candidates = provider.GetCandidateLibraries(); var candidates = provider.GetCandidateLibraries();
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Core
.Returns(new[] { CreateLibraryInfo("Bar") }); .Returns(new[] { CreateLibraryInfo("Bar") });
manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc")) manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc"))
.Returns(new[] { CreateLibraryInfo("Baz") }); .Returns(new[] { CreateLibraryInfo("Baz") });
var provider = new DefaultControllerAssemblyProvider(manager.Object); var provider = new DefaultAssemblyProvider(manager.Object);
// Act // Act
var candidates = provider.GetCandidateLibraries(); var candidates = provider.GetCandidateLibraries();

View File

@ -7,9 +7,9 @@ using System.Reflection;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
/// <summary> /// <summary>
/// An implementation of IControllerAssemblyProvider that provides just this assembly. /// An implementation of IAssemblyProvider that provides just this assembly.
/// </summary> /// </summary>
public class StaticControllerAssemblyProvider : IControllerAssemblyProvider public class StaticAssemblyProvider : IAssemblyProvider
{ {
public IEnumerable<Assembly> CandidateAssemblies public IEnumerable<Assembly> CandidateAssemblies
{ {

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
/// This is a generic type because it needs to instantiated by a service provider to replace /// This is a generic type because it needs to instantiated by a service provider to replace
/// a built-in MVC service. /// a built-in MVC service.
/// </remarks> /// </remarks>
public class TestAssemblyProvider<T> : IControllerAssemblyProvider public class TestAssemblyProvider<T> : IAssemblyProvider
{ {
public TestAssemblyProvider() public TestAssemblyProvider()
{ {

View File

@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var configuration = new TestConfigurationProvider(); var configuration = new TestConfigurationProvider();
configuration.Configuration.Set( configuration.Configuration.Set(
typeof(IControllerAssemblyProvider).FullName, typeof(IAssemblyProvider).FullName,
providerType.AssemblyQualifiedName); providerType.AssemblyQualifiedName);
services.AddInstance( services.AddInstance(

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
.Returns(GetGeneratorResult()) .Returns(GetGeneratorResult())
.Verifiable(); .Verifiable();
var ap = new Mock<IControllerAssemblyProvider>(); var ap = new Mock<IAssemblyProvider>();
ap.SetupGet(e => e.CandidateAssemblies) ap.SetupGet(e => e.CandidateAssemblies)
.Returns(Enumerable.Empty<Assembly>()) .Returns(Enumerable.Empty<Assembly>())
.Verifiable(); .Verifiable();
@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var host = new Mock<IMvcRazorHost>(); var host = new Mock<IMvcRazorHost>();
host.SetupAllProperties(); host.SetupAllProperties();
host.Setup(h => h.GenerateCode(It.IsAny<string>(), It.IsAny<Stream>())) host.Setup(h => h.GenerateCode(It.IsAny<string>(), It.IsAny<Stream>()))
.Returns(GetGeneratorResult()); var assemblyProvider = new Mock<IControllerAssemblyProvider>(); .Returns(GetGeneratorResult()); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider.SetupGet(e => e.CandidateAssemblies) assemblyProvider.SetupGet(e => e.CandidateAssemblies)
.Returns(Enumerable.Empty<Assembly>()); .Returns(Enumerable.Empty<Assembly>());

View File

@ -252,7 +252,7 @@ namespace System.Web.Http
private INestedProviderManager<ActionDescriptorProviderContext> CreateProvider() private INestedProviderManager<ActionDescriptorProviderContext> CreateProvider()
{ {
var assemblyProvider = new Mock<IControllerAssemblyProvider>(); var assemblyProvider = new Mock<IAssemblyProvider>();
assemblyProvider assemblyProvider
.SetupGet(ap => ap.CandidateAssemblies) .SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { typeof(ApiControllerActionDiscoveryTest).Assembly }); .Returns(new Assembly[] { typeof(ApiControllerActionDiscoveryTest).Assembly });