diff --git a/samples/MvcSample.Web/OverloadController.cs b/samples/MvcSample.Web/OverloadController.cs index faed44e111..9f39db037e 100644 --- a/samples/MvcSample.Web/OverloadController.cs +++ b/samples/MvcSample.Web/OverloadController.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.WebApiCompatShim; using MvcSample.Web.Models; diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintItem.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintItem.cs index 49b71906ef..301fcd1965 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintItem.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintItem.cs @@ -3,7 +3,7 @@ using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ActionConstraints { /// /// Represents an with or without a corresponding diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintProviderContext.cs index d2ca3fbc4e..303cef02bf 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ActionConstraintProviderContext.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ActionConstraints { /// /// Context for an action constraint provider. diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/DefaultActionConstraintProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/DefaultActionConstraintProvider.cs index b92be7d1f0..e73cfe0978 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/DefaultActionConstraintProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/DefaultActionConstraintProvider.cs @@ -2,20 +2,19 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ActionConstraints { /// - /// A default implementation of . + /// A default implementation of . /// /// /// This provider is able to provide an instance when the /// implements or /// / /// - public class DefaultActionConstraintProvider : INestedProvider + public class DefaultActionConstraintProvider : IActionConstraintProvider { /// public int Order @@ -24,14 +23,17 @@ namespace Microsoft.AspNet.Mvc } /// - public void Invoke([NotNull] ActionConstraintProviderContext context, [NotNull] Action callNext) + public void OnProvidersExecuting([NotNull] ActionConstraintProviderContext context) { foreach (var item in context.Results) { ProvideConstraint(item, context.HttpContext.RequestServices); } + } - callNext(); + /// + public void OnProvidersExecuted([NotNull] ActionConstraintProviderContext context) + { } private void ProvideConstraint(ActionConstraintItem item, IServiceProvider services) diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintFactory.cs index c59b8acddc..55b24e7a5a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintFactory.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ActionConstraints { /// /// A factory for . diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintProvider.cs new file mode 100644 index 0000000000..6777f88e9d --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/IActionConstraintProvider.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Mvc.ActionConstraints +{ + public interface IActionConstraintProvider + { + int Order { get; } + void OnProvidersExecuting([NotNull] ActionConstraintProviderContext context); + void OnProvidersExecuted([NotNull] ActionConstraintProviderContext context); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs index 76e18bd09b..844c08eb33 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs @@ -3,15 +3,10 @@ using System.Collections.Generic; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ActionDescriptorProviderContext { - public ActionDescriptorProviderContext() - { - Results = new List(); - } - - public IList Results { get; } + public IList Results { get; } = new List(); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionInvokerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ActionInvokerFactory.cs index 6cedd49f64..f34f2cd480 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionInvokerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionInvokerFactory.cs @@ -1,23 +1,34 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.DependencyInjection; +using System.Collections.Generic; +using System.Linq; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ActionInvokerFactory : IActionInvokerFactory { - private readonly INestedProviderManager _actionInvokerProvider; + private readonly IActionInvokerProvider[] _actionInvokerProviders; - public ActionInvokerFactory(INestedProviderManager actionInvokerProvider) + public ActionInvokerFactory(IEnumerable actionInvokerProviders) { - _actionInvokerProvider = actionInvokerProvider; + _actionInvokerProviders = actionInvokerProviders.OrderBy(item => item.Order).ToArray(); } public IActionInvoker CreateInvoker(ActionContext actionContext) { var context = new ActionInvokerProviderContext(actionContext); - _actionInvokerProvider.Invoke(context); + + foreach (var provider in _actionInvokerProviders) + { + provider.OnProvidersExecuting(context); + } + + for (var i = _actionInvokerProviders.Length - 1; i >= 0; i--) + { + _actionInvokerProviders[i].OnProvidersExecuted(context); + } + return context.Result; } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionInvokerProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/ActionInvokerProviderContext.cs index deae1190ce..4a1fb2ea97 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionInvokerProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionInvokerProviderContext.cs @@ -3,16 +3,16 @@ using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ActionInvokerProviderContext { - public ActionInvokerProviderContext([NotNull]ActionContext actionContext) + public ActionInvokerProviderContext([NotNull] ActionContext actionContext) { ActionContext = actionContext; } - public ActionContext ActionContext { get; private set; } + public ActionContext ActionContext { get; } public IActionInvoker Result { get; set; } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs index b13e514e44..686a7b6c13 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.AspNet.Mvc.Filters; @@ -10,7 +9,7 @@ using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; using Microsoft.Framework.OptionsModel; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ControllerActionDescriptorProvider : IActionDescriptorProvider { @@ -38,17 +37,21 @@ namespace Microsoft.AspNet.Mvc get { return DefaultOrder.DefaultFrameworkSortOrder; } } - public void Invoke(ActionDescriptorProviderContext context, Action callNext) + /// + public void OnProvidersExecuting ([NotNull] ActionDescriptorProviderContext context) { foreach (var descriptor in GetDescriptors()) { context.Results.Add(descriptor); } - - callNext(); } - public IEnumerable GetDescriptors() + /// + public void OnProvidersExecuted([NotNull] ActionDescriptorProviderContext context) + { + } + + internal protected IEnumerable GetDescriptors() { var applicationModel = BuildModel(); ApplicationModelConventions.ApplyConventions(applicationModel, _conventions); @@ -62,7 +65,7 @@ namespace Microsoft.AspNet.Mvc return ControllerActionDescriptorBuilder.Build(applicationModel); } - public ApplicationModel BuildModel() + internal protected ApplicationModel BuildModel() { var applicationModel = new ApplicationModel(); foreach (var filter in _globalFilters) diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs index 8243e575a1..af37f59642 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs @@ -5,12 +5,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ControllerActionInvoker : FilterActionInvoker { @@ -20,7 +19,7 @@ namespace Microsoft.AspNet.Mvc public ControllerActionInvoker( [NotNull] ActionContext actionContext, - [NotNull] INestedProviderManager filterProvider, + [NotNull] IReadOnlyList filterProviders, [NotNull] IControllerFactory controllerFactory, [NotNull] ControllerActionDescriptor descriptor, [NotNull] IInputFormattersProvider inputFormatterProvider, @@ -31,7 +30,7 @@ namespace Microsoft.AspNet.Mvc [NotNull] IScopedInstance actionBindingContextAccessor) : base( actionContext, - filterProvider, + filterProviders, inputFormatterProvider, modelBinderProvider, modelValidatorProviderProvider, diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvokerProvider.cs index a19e5031af..f3fcec1287 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvokerProvider.cs @@ -2,16 +2,19 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; +using System.Linq; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class ControllerActionInvokerProvider : IActionInvokerProvider { private readonly IControllerActionArgumentBinder _argumentBinder; private readonly IControllerFactory _controllerFactory; - private readonly INestedProviderManager _filterProvider; + private readonly IFilterProvider[] _filterProviders; private readonly IInputFormattersProvider _inputFormattersProvider; private readonly IModelBinderProvider _modelBinderProvider; private readonly IModelValidatorProviderProvider _modelValidationProviderProvider; @@ -21,7 +24,7 @@ namespace Microsoft.AspNet.Mvc public ControllerActionInvokerProvider( IControllerFactory controllerFactory, IInputFormattersProvider inputFormattersProvider, - INestedProviderManager filterProvider, + IEnumerable filterProviders, IControllerActionArgumentBinder argumentBinder, IModelBinderProvider modelBinderProvider, IModelValidatorProviderProvider modelValidationProviderProvider, @@ -30,7 +33,7 @@ namespace Microsoft.AspNet.Mvc { _controllerFactory = controllerFactory; _inputFormattersProvider = inputFormattersProvider; - _filterProvider = filterProvider; + _filterProviders = filterProviders.OrderBy(item => item.Order).ToArray(); _argumentBinder = argumentBinder; _modelBinderProvider = modelBinderProvider; _modelValidationProviderProvider = modelValidationProviderProvider; @@ -43,7 +46,8 @@ namespace Microsoft.AspNet.Mvc get { return DefaultOrder.DefaultFrameworkSortOrder; } } - public void Invoke(ActionInvokerProviderContext context, Action callNext) + /// + public void OnProvidersExecuting([NotNull] ActionInvokerProviderContext context) { var actionDescriptor = context.ActionContext.ActionDescriptor as ControllerActionDescriptor; @@ -51,7 +55,7 @@ namespace Microsoft.AspNet.Mvc { context.Result = new ControllerActionInvoker( context.ActionContext, - _filterProvider, + _filterProviders, _controllerFactory, actionDescriptor, _inputFormattersProvider, @@ -61,8 +65,11 @@ namespace Microsoft.AspNet.Mvc _valueProviderFactoryProvider, _actionBindingContextAccessor); } + } - callNext(); + /// + public void OnProvidersExecuted([NotNull] ActionInvokerProviderContext context) + { } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs index d4429a809f..85f13281e8 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs @@ -3,11 +3,12 @@ using System; using System.Collections.ObjectModel; +using System.Linq; using Microsoft.AspNet.Mvc.Logging; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { /// /// Default implementation for ActionDescriptors. @@ -47,22 +48,33 @@ namespace Microsoft.AspNet.Mvc private ActionDescriptorsCollection GetCollection() { - var actionDescriptorProvider = - _serviceProvider.GetRequiredService>(); - var actionDescriptorProviderContext = new ActionDescriptorProviderContext(); + var providers = + _serviceProvider.GetRequiredServices() + .OrderBy(p => p.Order) + .ToArray(); - actionDescriptorProvider.Invoke(actionDescriptorProviderContext); + var context = new ActionDescriptorProviderContext(); + + foreach (var provider in providers) + { + provider.OnProvidersExecuting(context); + } + + for (var i = providers.Length - 1; i >= 0; i--) + { + providers[i].OnProvidersExecuted(context); + } if (_logger.IsEnabled(LogLevel.Verbose)) { - foreach (var actionDescriptor in actionDescriptorProviderContext.Results) + foreach (var actionDescriptor in context.Results) { _logger.WriteVerbose(new ActionDescriptorValues(actionDescriptor)); } } return new ActionDescriptorsCollection( - new ReadOnlyCollection(actionDescriptorProviderContext.Results), 0); + new ReadOnlyCollection(context.Results), 0); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultActionSelector.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultActionSelector.cs index 64e6ca2e03..07a7aa054d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultActionSelector.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultActionSelector.cs @@ -6,32 +6,31 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Mvc.Core; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Routing; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public class DefaultActionSelector : IActionSelector { private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider; private readonly IActionSelectorDecisionTreeProvider _decisionTreeProvider; - private readonly INestedProviderManager _actionConstraintProvider; + private readonly IActionConstraintProvider[] _actionConstraintProviders; private ILogger _logger; public DefaultActionSelector( - [NotNull] IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider, - [NotNull] IActionSelectorDecisionTreeProvider decisionTreeProvider, - [NotNull] INestedProviderManager actionConstraintProvider, - [NotNull] ILoggerFactory loggerFactory) + IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider, + IActionSelectorDecisionTreeProvider decisionTreeProvider, + IEnumerable actionConstraintProviders, + ILoggerFactory loggerFactory) { _actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider; _decisionTreeProvider = decisionTreeProvider; - _actionConstraintProvider = actionConstraintProvider; + _actionConstraintProviders = actionConstraintProviders.OrderBy(item => item.Order).ToArray(); _logger = loggerFactory.Create(); } @@ -265,7 +264,15 @@ namespace Microsoft.AspNet.Mvc var items = action.ActionConstraints.Select(c => new ActionConstraintItem(c)).ToList(); var context = new ActionConstraintProviderContext(httpContext, action, items); - _actionConstraintProvider.Invoke(context); + foreach (var provider in _actionConstraintProviders) + { + provider.OnProvidersExecuting(context); + } + + for (var i = _actionConstraintProviders.Length - 1; i >= 0; i--) + { + _actionConstraintProviders[i].OnProvidersExecuted(context); + } return context.Results diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultAssemblyProvider.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultAssemblyProvider.cs index 0914afca47..18986c9c0c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultAssemblyProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultAssemblyProvider.cs @@ -34,6 +34,7 @@ namespace Microsoft.AspNet.Mvc "Microsoft.AspNet.Mvc.ModelBinding", "Microsoft.AspNet.Mvc.Razor", "Microsoft.AspNet.Mvc.Razor.Host", + "Microsoft.AspNet.Mvc.TagHelpers", }; /// diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionGroupCollectionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionGroupCollectionProvider.cs index 30edc5b6a9..6b72eb42b4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionGroupCollectionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionGroupCollectionProvider.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Linq; -using Microsoft.Framework.DependencyInjection; namespace Microsoft.AspNet.Mvc.Description { @@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc.Description public class ApiDescriptionGroupCollectionProvider : IApiDescriptionGroupCollectionProvider { private readonly IActionDescriptorsCollectionProvider _actionDescriptorCollectionProvider; - private readonly INestedProviderManager _apiDescriptionProvider; + private readonly IApiDescriptionProvider[] _apiDescriptionProviders; private ApiDescriptionGroupCollection _apiDescriptionGroups; @@ -20,15 +20,15 @@ namespace Microsoft.AspNet.Mvc.Description /// /// The . /// - /// - /// The . + /// + /// The . /// public ApiDescriptionGroupCollectionProvider( IActionDescriptorsCollectionProvider actionDescriptorCollectionProvider, - INestedProviderManager apiDescriptionProvider) + IEnumerable apiDescriptionProviders) { _actionDescriptorCollectionProvider = actionDescriptorCollectionProvider; - _apiDescriptionProvider = apiDescriptionProvider; + _apiDescriptionProviders = apiDescriptionProviders.OrderBy(item => item.Order).ToArray(); } /// @@ -49,7 +49,16 @@ namespace Microsoft.AspNet.Mvc.Description private ApiDescriptionGroupCollection GetCollection(ActionDescriptorsCollection actionDescriptors) { var context = new ApiDescriptionProviderContext(actionDescriptors.Items); - _apiDescriptionProvider.Invoke(context); + + foreach (var provider in _apiDescriptionProviders) + { + provider.OnProvidersExecuting(context); + } + + for (var i = _apiDescriptionProviders.Length - 1; i >= 0; i--) + { + _apiDescriptionProviders[i].OnProvidersExecuted(context); + } var groups = context.Results .GroupBy(d => d.GroupName) diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs index a351017d10..2fd75bea82 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing.Template; +using Microsoft.Framework.Internal; using Microsoft.Net.Http.Headers; -using Microsoft.Framework.DependencyInjection; namespace Microsoft.AspNet.Mvc.Description { @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Description /// Implements a provider of for actions represented /// by . /// - public class DefaultApiDescriptionProvider : INestedProvider + public class DefaultApiDescriptionProvider : IApiDescriptionProvider { private readonly IOutputFormattersProvider _formattersProvider; private readonly IModelMetadataProvider _modelMetadataProvider; @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Description } /// - public void Invoke(ApiDescriptionProviderContext context, Action callNext) + public void OnProvidersExecuting([NotNull] ApiDescriptionProviderContext context) { foreach (var action in context.Actions.OfType()) { @@ -59,8 +59,10 @@ namespace Microsoft.AspNet.Mvc.Description } } } + } - callNext(); + public void OnProvidersExecuted([NotNull] ApiDescriptionProviderContext context) + { } private ApiDescription CreateApiDescription( diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/IApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/IApiDescriptionProvider.cs new file mode 100644 index 0000000000..fd8e0d1d7c --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Description/IApiDescriptionProvider.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Mvc.Description +{ + public interface IApiDescriptionProvider + { + int Order { get; } + void OnProvidersExecuting([NotNull] ApiDescriptionProviderContext context); + void OnProvidersExecuted([NotNull] ApiDescriptionProviderContext context); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs index 0a8b64864a..80683d4c7b 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs @@ -7,16 +7,15 @@ using System.Diagnostics; using System.Linq; using System.Runtime.ExceptionServices; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { public abstract class FilterActionInvoker : IActionInvoker { - private readonly INestedProviderManager _filterProvider; + private readonly IReadOnlyList _filterProviders; private readonly IInputFormattersProvider _inputFormatterProvider; private readonly IModelBinderProvider _modelBinderProvider; private readonly IModelValidatorProviderProvider _modelValidatorProviderProvider; @@ -41,7 +40,7 @@ namespace Microsoft.AspNet.Mvc public FilterActionInvoker( [NotNull] ActionContext actionContext, - [NotNull] INestedProviderManager filterProvider, + [NotNull] IReadOnlyList filterProviders, [NotNull] IInputFormattersProvider inputFormatterProvider, [NotNull] IModelBinderProvider modelBinderProvider, [NotNull] IModelValidatorProviderProvider modelValidatorProviderProvider, @@ -50,7 +49,7 @@ namespace Microsoft.AspNet.Mvc { ActionContext = actionContext; - _filterProvider = filterProvider; + _filterProviders = filterProviders; _inputFormatterProvider = inputFormatterProvider; _modelBinderProvider = modelBinderProvider; _modelValidatorProviderProvider = modelValidatorProviderProvider; @@ -142,13 +141,21 @@ namespace Microsoft.AspNet.Mvc private IFilter[] GetFilters() { - var filterProviderContext = new FilterProviderContext( + var context = new FilterProviderContext( ActionContext, ActionContext.ActionDescriptor.FilterDescriptors.Select(fd => new FilterItem(fd)).ToList()); - _filterProvider.Invoke(filterProviderContext); + foreach (var provider in _filterProviders) + { + provider.OnProvidersExecuting(context); + } - return filterProviderContext.Results.Select(item => item.Filter).Where(filter => filter != null).ToArray(); + for (var i = _filterProviders.Count - 1; i >= 0; i--) + { + _filterProviders[i].OnProvidersExecuted(context); + } + + return context.Results.Select(item => item.Filter).Where(filter => filter != null).ToArray(); } private async Task InvokeAllAuthorizationFiltersAsync() diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs index 70934c4911..64fca021be 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs @@ -4,11 +4,11 @@ using System; using System.Diagnostics; using Microsoft.AspNet.Mvc.Core; -using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.Filters { - public class DefaultFilterProvider : INestedProvider + public class DefaultFilterProvider : IFilterProvider { public DefaultFilterProvider(IServiceProvider serviceProvider) { @@ -22,7 +22,8 @@ namespace Microsoft.AspNet.Mvc.Filters protected IServiceProvider ServiceProvider { get; private set; } - public virtual void Invoke(FilterProviderContext context, Action callNext) + /// + public void OnProvidersExecuting([NotNull] FilterProviderContext context) { if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) { @@ -31,11 +32,11 @@ namespace Microsoft.AspNet.Mvc.Filters ProvideFilter(context, item); } } + } - if (callNext != null) - { - callNext(); - } + /// + public void OnProvidersExecuted([NotNull] FilterProviderContext context) + { } public virtual void ProvideFilter(FilterProviderContext context, FilterItem filterItem) diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/IFilterProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/IFilterProvider.cs new file mode 100644 index 0000000000..7b0940f470 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/IFilterProvider.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Mvc.Core +{ + public interface IFilterProvider + { + int Order { get; } + void OnProvidersExecuting([NotNull] FilterProviderContext context); + void OnProvidersExecuted([NotNull] FilterProviderContext context); + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/IActionDescriptorProvider.cs b/src/Microsoft.AspNet.Mvc.Core/IActionDescriptorProvider.cs index 92f19503c7..82e8768e13 100644 --- a/src/Microsoft.AspNet.Mvc.Core/IActionDescriptorProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/IActionDescriptorProvider.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { - public interface IActionDescriptorProvider : INestedProvider + public interface IActionDescriptorProvider { + int Order { get; } + void OnProvidersExecuting([NotNull] ActionDescriptorProviderContext context); + void OnProvidersExecuted([NotNull] ActionDescriptorProviderContext context); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/IActionInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/IActionInvokerProvider.cs index 68f8f42907..8d6d5ed990 100644 --- a/src/Microsoft.AspNet.Mvc.Core/IActionInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/IActionInvokerProvider.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.Core { - public interface IActionInvokerProvider : INestedProvider + public interface IActionInvokerProvider { + int Order { get; } + void OnProvidersExecuting([NotNull] ActionInvokerProviderContext context); + void OnProvidersExecuted([NotNull] ActionInvokerProviderContext context); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Internal/NestedProviders/NestedProviderManager.cs b/src/Microsoft.AspNet.Mvc.Core/Internal/NestedProviders/NestedProviderManager.cs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/ActionConstraintValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/ActionConstraintValues.cs index af798e4519..11f9bf9430 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/ActionConstraintValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/ActionConstraintValues.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.Framework.Logging; namespace Microsoft.AspNet.Mvc.Logging diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs index e5f85b3202..2341a4c0c5 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs @@ -7,7 +7,7 @@ using System.Text; namespace Microsoft.AspNet.Mvc.Logging { /// - /// Represents the state of . + /// Represents the state of . /// public class DefaultActionSelectorSelectAsyncValues { diff --git a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ModelBinderDescriptorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ModelBinderDescriptorExtensions.cs index 5060d58319..ee692f12ba 100644 --- a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ModelBinderDescriptorExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ModelBinderDescriptorExtensions.cs @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Mvc public static void RemoveTypesOf([NotNull] this IList descriptors) where TInstance : class, IModelBinder { - for (int i = descriptors.Count - 1; i >= 0; i--) + for (var i = descriptors.Count - 1; i >= 0; i--) { if (descriptors[i].OptionType == typeof(TInstance)) { diff --git a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/OutputFormatterDescriptorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/OutputFormatterDescriptorExtensions.cs index 298cedaa8a..8181775157 100644 --- a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/OutputFormatterDescriptorExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/OutputFormatterDescriptorExtensions.cs @@ -90,7 +90,7 @@ namespace Microsoft.AspNet.Mvc public static void RemoveTypesOf([NotNull] this IList descriptors) where TInstance : class, IOutputFormatter { - for (int i = descriptors.Count - 1; i >= 0; i--) + for (var i = descriptors.Count - 1; i >= 0; i--) { if (descriptors[i].OptionType == typeof(TInstance)) { diff --git a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ValueProviderFactoryDescriptorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ValueProviderFactoryDescriptorExtensions.cs index 304809e56a..a274b518f3 100644 --- a/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ValueProviderFactoryDescriptorExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/ValueProviderFactoryDescriptorExtensions.cs @@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Mvc public static void RemoveTypesOf([NotNull] this IList descriptors) where TInstance : class, IValueProviderFactory { - for (int i = descriptors.Count - 1; i >= 0; i--) + for (var i = descriptors.Count - 1; i >= 0; i--) { if (descriptors[i].OptionType == typeof(TInstance)) { diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentHelper.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentHelper.cs index 5a88e8da04..8e6a868296 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentHelper.cs @@ -9,7 +9,7 @@ using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { public class DefaultViewComponentHelper : IViewComponentHelper, ICanHasViewContext { diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerFactory.cs index 6a4aabd02f..5bbaa6eb60 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerFactory.cs @@ -1,26 +1,37 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; +using System.Linq; using System.Reflection; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { public class DefaultViewComponentInvokerFactory : IViewComponentInvokerFactory { - private readonly INestedProviderManager _providerManager; + private readonly IViewComponentInvokerProvider[] _providers; public DefaultViewComponentInvokerFactory( - INestedProviderManager providerManager) + IEnumerable providers) { - _providerManager = providerManager; + _providers = providers.OrderBy(item => item.Order).ToArray(); } public IViewComponentInvoker CreateInstance([NotNull] TypeInfo componentType, object[] args) { var context = new ViewComponentInvokerProviderContext(componentType, args); - _providerManager.Invoke(context); + + foreach (var provider in _providers) + { + provider.OnProvidersExecuting(context); + } + + for (var i = _providers.Length - 1; i >= 0; i--) + { + _providers[i].OnProvidersExecuted(context); + } + return context.Result; } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerProvider.cs index 53a7ce6440..d0f2d16605 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentInvokerProvider.cs @@ -2,10 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { public class DefaultViewComponentInvokerProvider : IViewComponentInvokerProvider { @@ -28,7 +27,8 @@ namespace Microsoft.AspNet.Mvc get { return DefaultOrder.DefaultFrameworkSortOrder; } } - public void Invoke([NotNull] ViewComponentInvokerProviderContext context, [NotNull] Action callNext) + /// + public void OnProvidersExecuting([NotNull] ViewComponentInvokerProviderContext context) { context.Result = new DefaultViewComponentInvoker( _serviceProvider, @@ -36,8 +36,11 @@ namespace Microsoft.AspNet.Mvc _viewComponentActivator, context.ComponentType, context.Arguments); + } - callNext(); + /// + public void OnProvidersExecuted([NotNull] ViewComponentInvokerProviderContext context) + { } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerFactory.cs index 9f1cc938e6..12cb46aa28 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerFactory.cs @@ -4,7 +4,7 @@ using System.Reflection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { public interface IViewComponentInvokerFactory { diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerProvider.cs index 7a94784f37..5580449f50 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentInvokerProvider.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { - public interface IViewComponentInvokerProvider : INestedProvider + public interface IViewComponentInvokerProvider { + int Order { get; } + void OnProvidersExecuting([NotNull] ViewComponentInvokerProviderContext context); + void OnProvidersExecuted([NotNull] ViewComponentInvokerProviderContext context); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponentInvokerProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponentInvokerProviderContext.cs index 2a67892771..cda03c4a49 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponentInvokerProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponentInvokerProviderContext.cs @@ -4,7 +4,7 @@ using System.Reflection; using Microsoft.Framework.Internal; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ViewComponents { public class ViewComponentInvokerProviderContext { diff --git a/src/Microsoft.AspNet.Mvc/MvcServices.cs b/src/Microsoft.AspNet.Mvc/MvcServices.cs index 6a9ae9ee95..a87f92b9af 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServices.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServices.cs @@ -2,7 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.ApplicationModels; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Internal; @@ -13,10 +15,10 @@ using Microsoft.AspNet.Mvc.Razor.Directives; using Microsoft.AspNet.Mvc.Razor.OptionDescriptors; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Routing; +using Microsoft.AspNet.Mvc.ViewComponents; using Microsoft.Framework.Cache.Memory; using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.NestedProviders; using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Mvc @@ -58,24 +60,16 @@ namespace Microsoft.AspNet.Mvc // This provider needs access to the per-request services, but might be used many times for a given // request. - yield return describe.Transient, - NestedProviderManager>(); - yield return describe.Transient, - DefaultActionConstraintProvider>(); + yield return describe.Transient(); yield return describe.Singleton(); yield return describe.Singleton(); yield return describe.Transient(); yield return describe.Transient(); - yield return describe.Transient, - NestedProviderManager>(); - yield return describe.Transient, - ControllerActionDescriptorProvider>(); + yield return describe.Transient(); - yield return describe.Transient, - NestedProviderManager>(); - yield return describe.Transient, + yield return describe.Transient(); yield return describe.Singleton(); - yield return describe.Transient, - NestedProviderManager>(); - yield return describe.Transient, DefaultFilterProvider>(); + yield return describe.Transient(); yield return describe.Transient(); // Dataflow - ModelBinding, Validation and Formatting @@ -165,10 +157,7 @@ namespace Microsoft.AspNet.Mvc yield return describe.Singleton(); yield return describe.Transient(); - yield return describe.Transient, - NestedProviderManager>(); - yield return describe.Transient, - DefaultViewComponentInvokerProvider>(); + yield return describe.Transient(); yield return describe.Transient(); // Security and Authorization @@ -178,12 +167,9 @@ namespace Microsoft.AspNet.Mvc DefaultAntiForgeryAdditionalDataProvider>(); // Api Description - yield return describe.Transient, - NestedProviderManager>(); yield return describe.Singleton(); - yield return describe.Transient, - DefaultApiDescriptionProvider>(); + yield return describe.Transient(); } } } diff --git a/test/Microsoft.AspNet.Mvc.Common.Test/project.json b/test/Microsoft.AspNet.Mvc.Common.Test/project.json index 8339e4b2a3..879667965c 100644 --- a/test/Microsoft.AspNet.Mvc.Common.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Common.Test/project.json @@ -1,13 +1,14 @@ { "compilationOptions": { - "warningsAsErrors": "true" + "warningsAsErrors": true }, "dependencies": { "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Testing": "1.0.0-*", "Microsoft.Framework.CopyOnWriteDictionary.Internal": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" }, - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*", + "Microsoft.Framework.DependencyInjection": "1.0.0-*" }, "commands": { "test": "xunit.runner.kre" diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ActionConstraintValuesTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ActionConstraintValuesTest.cs index 804673d333..6f290cc53e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ActionConstraintValuesTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ActionConstraintValuesTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Mvc.ActionConstraints; using Xunit; namespace Microsoft.AspNet.Mvc.Logging diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs index bde1bb457d..78844d9182 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs @@ -6,10 +6,10 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using Microsoft.AspNet.Mvc.ApplicationModels; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Routing; using Microsoft.Framework.Internal; -using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs index 0da32e5b73..08b2fb63fd 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs @@ -3,12 +3,14 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Core; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Testing; @@ -1976,9 +1978,9 @@ namespace Microsoft.AspNet.Mvc routeData: new RouteData(), actionDescriptor: actionDescriptor); - var filterProvider = new Mock>(MockBehavior.Strict); + var filterProvider = new Mock(MockBehavior.Strict); filterProvider - .Setup(fp => fp.Invoke(It.IsAny())) + .Setup(fp => fp.OnProvidersExecuting(It.IsAny())) .Callback(context => { foreach (var filter in filters.Select(f => new FilterItem(null, f))) @@ -1987,6 +1989,13 @@ namespace Microsoft.AspNet.Mvc } }); + filterProvider.Setup(fp => fp.OnProvidersExecuted(It.IsAny())) + .Verifiable(); + + filterProvider.SetupGet(fp => fp.Order) + .Returns(DefaultOrder.DefaultFrameworkSortOrder); + + var inputFormattersProvider = new Mock(); inputFormattersProvider.SetupGet(o => o.InputFormatters) .Returns(new List()); @@ -1995,7 +2004,7 @@ namespace Microsoft.AspNet.Mvc .Returns(new List()); var invoker = new TestControllerActionInvoker( actionContext, - filterProvider.Object, + new[] { filterProvider.Object }, new MockControllerFactory(this), actionDescriptor, inputFormattersProvider.Object, @@ -2047,7 +2056,7 @@ namespace Microsoft.AspNet.Mvc var metadataProvider = new EmptyModelMetadataProvider(); var invoker = new ControllerActionInvoker( actionContext, - Mock.Of>(), + new List(), controllerFactory.Object, actionDescriptor, inputFormattersProvider.Object, @@ -2147,7 +2156,7 @@ namespace Microsoft.AspNet.Mvc { public TestControllerActionInvoker( ActionContext actionContext, - INestedProviderManager filterProvider, + IFilterProvider[] filterProvider, MockControllerFactory controllerFactory, ControllerActionDescriptor descriptor, IInputFormattersProvider inputFormattersProvider, diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionDescriptorCollectionProviderLoggingTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionDescriptorCollectionProviderLoggingTest.cs index ead46a83e0..54919525ee 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionDescriptorCollectionProviderLoggingTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionDescriptorCollectionProviderLoggingTest.cs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.ComponentModel.Design; using System.Linq; using System.Reflection; using Microsoft.AspNet.Mvc.ApplicationModels; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Security; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.NestedProviders; using Microsoft.Framework.Logging; using Xunit; @@ -109,12 +109,15 @@ namespace Microsoft.AspNet.Mvc.Logging private void CreateActionDescriptors(ILoggerFactory loggerFactory, params TypeInfo[] controllerTypeInfo) { var actionDescriptorProvider = GetProvider(loggerFactory, controllerTypeInfo); - var descriptorProvider = - new NestedProviderManager(new[] { actionDescriptorProvider }); + // service container does not work quite like our built in Depenency Injection container. var serviceContainer = new ServiceContainer(); - serviceContainer.AddService(typeof(INestedProviderManager), - descriptorProvider); + var list = new List() + { + actionDescriptorProvider, + }; + + serviceContainer.AddService(typeof(IEnumerable), list); var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer, loggerFactory); var descriptors = actionCollectionDescriptorProvider.ActionDescriptors; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs index 8276a8ab76..26d9d9a698 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs @@ -9,12 +9,12 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Core; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.ApplicationModels; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Routing; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.NestedProviders; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; using Moq; @@ -733,26 +733,27 @@ namespace Microsoft.AspNet.Mvc private async Task InvokeActionSelector(RouteContext context) { var actionDescriptorProvider = GetActionDescriptorProvider(); - var descriptorProvider = - new NestedProviderManager(new[] { actionDescriptorProvider }); + // service container does not work quite like our built in Depenency Injection container. var serviceContainer = new ServiceContainer(); - serviceContainer.AddService(typeof(INestedProviderManager), - descriptorProvider); + var list = new List() + { + actionDescriptorProvider, + }; + + serviceContainer.AddService(typeof(IEnumerable), list); var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer, new NullLoggerFactory()); var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionCollectionDescriptorProvider); - var actionConstraintProvider = new NestedProviderManager( - new INestedProvider[] - { - new DefaultActionConstraintProvider(), - }); + var actionConstraintProviders = new IActionConstraintProvider[] { + new DefaultActionConstraintProvider(), + }; var defaultActionSelector = new DefaultActionSelector( actionCollectionDescriptorProvider, decisionTreeProvider, - actionConstraintProvider, + actionConstraintProviders, NullLoggerFactory.Instance); return await defaultActionSelector.SelectAsync(context); @@ -829,17 +830,15 @@ namespace Microsoft.AspNet.Mvc var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionProvider.Object); - var actionConstraintProvider = new NestedProviderManager( - new INestedProvider[] - { - new DefaultActionConstraintProvider(), - new BooleanConstraintProvider(), - }); + var actionConstraintProviders = new IActionConstraintProvider[] { + new DefaultActionConstraintProvider(), + new BooleanConstraintProvider(), + }; return new DefaultActionSelector( actionProvider.Object, decisionTreeProvider, - actionConstraintProvider, + actionConstraintProviders, loggerFactory); } @@ -932,11 +931,11 @@ namespace Microsoft.AspNet.Mvc public bool Pass { get; set; } } - private class BooleanConstraintProvider : INestedProvider + private class BooleanConstraintProvider : IActionConstraintProvider { public int Order { get; set; } - public void Invoke(ActionConstraintProviderContext context, Action callNext) + public void OnProvidersExecuting(ActionConstraintProviderContext context) { foreach (var item in context.Results) { @@ -947,8 +946,10 @@ namespace Microsoft.AspNet.Mvc item.Constraint = new BooleanConstraint() { Pass = marker.Pass }; } } + } - callNext(); + public void OnProvidersExecuted(ActionConstraintProviderContext context) + { } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs index efd5878343..b29416d60e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs @@ -925,7 +925,9 @@ namespace Microsoft.AspNet.Mvc.Description constraintResolver.Object, modelMetadataProvider); - provider.Invoke(context, () => { }); + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); + return new ReadOnlyCollection(context.Results); } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/DefaultFilterProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/DefaultFilterProviderTest.cs index b30b13543a..9927468043 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/DefaultFilterProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/DefaultFilterProviderTest.cs @@ -28,7 +28,9 @@ namespace Microsoft.AspNet.Mvc.Filters var provider = CreateProvider(); // Act - provider.Invoke(context, () => { }); + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); + var results = context.Results; // Assert @@ -57,7 +59,9 @@ namespace Microsoft.AspNet.Mvc.Filters var provider = CreateProvider(); // Act - provider.Invoke(context, () => { }); + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); + var results = context.Results; // Assert @@ -88,7 +92,8 @@ namespace Microsoft.AspNet.Mvc.Filters var provider = CreateProvider(); // Act - provider.Invoke(context, () => { }); + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); var results = context.Results; // Assert @@ -118,7 +123,8 @@ namespace Microsoft.AspNet.Mvc.Filters var provider = CreateProvider(); // Act - provider.Invoke(context, () => { }); + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); var results = context.Results; // Assert diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/KnownRouteValueConstraintTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/KnownRouteValueConstraintTests.cs index 4cda51fa84..56a056fc2e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/KnownRouteValueConstraintTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/KnownRouteValueConstraintTests.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; -using Microsoft.Framework.DependencyInjection; +using Microsoft.AspNet.Mvc.Core; using Moq; using Xunit; @@ -151,17 +151,25 @@ namespace Microsoft.AspNet.Routing.Tests private static HttpContext GetHttpContext(ActionDescriptor actionDescriptor) { - var actionProvider = new Mock>( - MockBehavior.Strict); + var actionProvider = new Mock(MockBehavior.Strict); actionProvider - .Setup(p => p.Invoke(It.IsAny())) + .SetupGet(p => p.Order) + .Returns(DefaultOrder.DefaultFrameworkSortOrder); + + actionProvider + .Setup(p => p.OnProvidersExecuting(It.IsAny())) .Callback(c => c.Results.Add(actionDescriptor)); + actionProvider + .Setup(p => p.OnProvidersExecuted(It.IsAny())) + .Verifiable(); + var context = new Mock(); context.Setup(o => o.RequestServices - .GetService(typeof(INestedProviderManager))) - .Returns(actionProvider.Object); + .GetService(typeof(IEnumerable))) + .Returns(new[] { actionProvider.Object }); + context.Setup(o => o.RequestServices .GetService(typeof(IActionDescriptorsCollectionProvider))) .Returns(new DefaultActionDescriptorsCollectionProvider(context.Object.RequestServices, new NullLoggerFactory())); diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ControllerDiscoveryConventionTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ControllerDiscoveryConventionTests.cs index 8a07749484..53481f4a3e 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ControllerDiscoveryConventionTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ControllerDiscoveryConventionTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Net; using System.Threading.Tasks; diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/DefaultOrderTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/DefaultOrderTest.cs index 2c7eec5bd7..19c890ea85 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/DefaultOrderTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/DefaultOrderTest.cs @@ -5,10 +5,12 @@ using System; using System.Net; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Mvc.ActionConstraints; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Razor; +using Microsoft.AspNet.Mvc.ViewComponents; using Microsoft.AspNet.TestHost; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.OptionsModel; using Xunit; @@ -21,13 +23,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new BasicWebSite.Startup().Configure; [Theory] - [InlineData(typeof(INestedProvider), typeof(ControllerActionDescriptorProvider), -1000)] - [InlineData(typeof(INestedProvider), (Type)null, -1000)] - [InlineData(typeof(INestedProvider), (Type)null, -1000)] - [InlineData(typeof(INestedProvider), (Type)null, -1000)] - [InlineData(typeof(INestedProvider), (Type)null, -1000)] - [InlineData(typeof(IConfigureOptions), (Type)null, -1000)] - [InlineData(typeof(IConfigureOptions), (Type)null, -1000)] + [InlineData(typeof(IActionDescriptorProvider), typeof(ControllerActionDescriptorProvider), -1000)] + [InlineData(typeof(IActionInvokerProvider), null, -1000)] + [InlineData(typeof(IApiDescriptionProvider), null, -1000)] + [InlineData(typeof(IFilterProvider), null, -1000)] + [InlineData(typeof(IViewComponentInvokerProvider), null, -1000)] + [InlineData(typeof(IActionConstraintProvider), null, -1000)] + [InlineData(typeof(IConfigureOptions), null, -1000)] + [InlineData(typeof(IConfigureOptions), null, -1000)] public async Task ServiceOrder_GetOrder(Type serviceType, Type actualType, int order) { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs index f84ef77be8..2059bbeae7 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs @@ -11,8 +11,6 @@ using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.WebApiCompatShim; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.NestedProviders; using Microsoft.Framework.Logging; using Microsoft.Framework.OptionsModel; using Moq; @@ -30,7 +28,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -49,7 +47,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -68,7 +66,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -104,7 +102,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -140,7 +138,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -177,7 +175,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -213,7 +211,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -238,7 +236,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -263,7 +261,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -291,7 +289,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -318,7 +316,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -347,7 +345,7 @@ namespace System.Web.Http // Act var context = new ActionDescriptorProviderContext(); - provider.Invoke(context); + Invoke(provider, context); var results = context.Results.Cast(); @@ -367,7 +365,7 @@ namespace System.Web.Http } } - private INestedProviderManager CreateProvider() + private ControllerActionDescriptorProvider CreateProvider() { var assemblyProvider = new FixedSetAssemblyProvider(); assemblyProvider.CandidateAssemblies.Add(GetType().GetTypeInfo().Assembly); @@ -398,11 +396,13 @@ namespace System.Web.Http optionsAccessor.Object, new NullLoggerFactory()); - return new NestedProviderManager( - new INestedProvider[] - { - provider - }); + return provider; + } + + private void Invoke(ControllerActionDescriptorProvider provider, ActionDescriptorProviderContext context) + { + provider.OnProvidersExecuting(context); + provider.OnProvidersExecuted(context); } private class NamespaceFilteredControllerTypeProvider : DefaultControllerTypeProvider diff --git a/test/WebSites/BasicWebSite/ActionDescriptorCreationCounter.cs b/test/WebSites/BasicWebSite/ActionDescriptorCreationCounter.cs index aa8b35c55e..9a4e25dfcd 100644 --- a/test/WebSites/BasicWebSite/ActionDescriptorCreationCounter.cs +++ b/test/WebSites/BasicWebSite/ActionDescriptorCreationCounter.cs @@ -4,6 +4,7 @@ using System; using System.Threading; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Core; namespace BasicWebSite { @@ -29,10 +30,12 @@ namespace BasicWebSite } } - public void Invoke(ActionDescriptorProviderContext context, Action callNext) + public void OnProvidersExecuting(ActionDescriptorProviderContext context) { - callNext(); + } + public void OnProvidersExecuted(ActionDescriptorProviderContext context) + { if (context.Results.Count == 0) { throw new InvalidOperationException("No actions found!"); diff --git a/test/WebSites/BasicWebSite/Controllers/MonitorController.cs b/test/WebSites/BasicWebSite/Controllers/MonitorController.cs index ad9802a220..f5ea1c1a1d 100644 --- a/test/WebSites/BasicWebSite/Controllers/MonitorController.cs +++ b/test/WebSites/BasicWebSite/Controllers/MonitorController.cs @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Globalization; +using System.Linq; using Microsoft.AspNet.Mvc; -using Microsoft.Framework.DependencyInjection; +using Microsoft.AspNet.Mvc.Core; namespace BasicWebSite { @@ -11,9 +13,9 @@ namespace BasicWebSite { private readonly ActionDescriptorCreationCounter _counterService; - public MonitorController(INestedProvider counterService) + public MonitorController(IEnumerable providers) { - _counterService = (ActionDescriptorCreationCounter)counterService; + _counterService = providers.OfType().Single(); } public IActionResult CountActionDescriptorInvocations() diff --git a/test/WebSites/BasicWebSite/Startup.cs b/test/WebSites/BasicWebSite/Startup.cs index 7c9eda58fd..c0adabf28d 100644 --- a/test/WebSites/BasicWebSite/Startup.cs +++ b/test/WebSites/BasicWebSite/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.DependencyInjection; namespace BasicWebSite @@ -19,7 +20,7 @@ namespace BasicWebSite // Add MVC services to the services container services.AddMvc(configuration); - services.AddSingleton, ActionDescriptorCreationCounter>(); + services.AddSingleton(); services.ConfigureMvcOptions(options => { diff --git a/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs b/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs index 54b9224a1f..b96329463c 100644 --- a/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs +++ b/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Concurrent; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.Framework.DependencyInjection; namespace RequestServicesWebSite diff --git a/test/WebSites/VersioningWebSite/VersionAttribute.cs b/test/WebSites/VersioningWebSite/VersionAttribute.cs index 0fb413db11..29f0f74500 100644 --- a/test/WebSites/VersioningWebSite/VersionAttribute.cs +++ b/test/WebSites/VersioningWebSite/VersionAttribute.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.ActionConstraints; namespace VersioningWebSite { diff --git a/test/WebSites/VersioningWebSite/VersionRoute.cs b/test/WebSites/VersioningWebSite/VersionRoute.cs index 117072cdde..e8dc6fc8e5 100644 --- a/test/WebSites/VersioningWebSite/VersionRoute.cs +++ b/test/WebSites/VersioningWebSite/VersionRoute.cs @@ -4,6 +4,7 @@ using System; using System.Text.RegularExpressions; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.ActionConstraints; namespace VersioningWebSite {