Issue #1176: Renaming ActionDescriptor, ActionDescriptorProvider, ActionInvoker, ActionInvokerProvider, ActionExecutor, ModelBuilder, Tests. Either dropping "Reflected" or changing it to "Controller" depending on the context.

This commit is contained in:
sornaks 2014-10-06 14:42:23 -07:00
parent 144a4b5921
commit a88f59fc49
47 changed files with 435 additions and 434 deletions

51
Mvc.sln
View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22130.0
VisualStudioVersion = 14.0.22013.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
EndProject
@ -81,14 +81,15 @@ EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UrlHelperWebSite", "test\WebSites\UrlHelperWebSite\UrlHelperWebSite.kproj", "{A192E504-2881-41DC-90D1-B7F1DD1134E8}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApiExplorerWebSite", "test\WebSites\ApiExplorerWebSite\ApiExplorerWebSite.kproj", "{61061528-071E-424E-965A-07BCC2F02672}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "VersioningWebSite", "test\WebSites\VersioningWebSite\VersioningWebSite.kproj", "{C6304029-78C8-4604-99BE-2078DCA1DD36}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ReflectedModelWebSite", "test\WebSites\ReflectedModelWebSite\ReflectedModelWebSite.kproj", "{C2EF54F8-8886-4260-A322-44F76245F95D}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "VersioningWebSite", "test\WebSites\VersioningWebSite\VersioningWebSite.kproj", "{C6304029-78C8-4604-99BE-2078DCA1DD36}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FilesWebSite", "test\WebSites\FilesWebSite\FilesWebSite.kproj", "{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorInstrumentationWebSite", "test\WebSites\RazorInstrumentationWebSite\RazorInstrumentationWebSite.kproj", "{2B2B9876-903C-4065-8D62-2EE832BBA106}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationModelWebSite", "test\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.kproj", "{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -419,16 +420,6 @@ Global
{A192E504-2881-41DC-90D1-B7F1DD1134E8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A192E504-2881-41DC-90D1-B7F1DD1134E8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A192E504-2881-41DC-90D1-B7F1DD1134E8}.Release|x86.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|x86.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.Build.0 = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|x86.ActiveCfg = Release|Any CPU
{61061528-071E-424E-965A-07BCC2F02672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61061528-071E-424E-965A-07BCC2F02672}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61061528-071E-424E-965A-07BCC2F02672}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -449,16 +440,16 @@ Global
{C6304029-78C8-4604-99BE-2078DCA1DD36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C6304029-78C8-4604-99BE-2078DCA1DD36}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C6304029-78C8-4604-99BE-2078DCA1DD36}.Release|x86.ActiveCfg = Release|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|x86.ActiveCfg = Debug|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Any CPU.Build.0 = Release|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|x86.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|x86.ActiveCfg = Debug|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.Build.0 = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|x86.ActiveCfg = Release|Any CPU
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -469,6 +460,16 @@ Global
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|x86.ActiveCfg = Release|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|x86.ActiveCfg = Debug|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Any CPU.Build.0 = Release|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -507,10 +508,10 @@ Global
{1976AC4A-FEA4-4587-A158-D9F79736D2B6} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{96107AC0-18E2-474D-BAB4-2FFF2185FBCD} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{A192E504-2881-41DC-90D1-B7F1DD1134E8} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{61061528-071E-424E-965A-07BCC2F02672} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{C6304029-78C8-4604-99BE-2078DCA1DD36} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{C2EF54F8-8886-4260-A322-44F76245F95D} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{2B2B9876-903C-4065-8D62-2EE832BBA106} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
EndGlobalSection
EndGlobal

View File

@ -2,20 +2,20 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace MvcSample.Web
{
// Adds an auto-generated route-name to each action in the controller
public class AutoGenerateRouteNamesAttribute : Attribute, IReflectedControllerModelConvention
public class AutoGenerateRouteNamesAttribute : Attribute, IControllerModelConvention
{
public void Apply(ReflectedControllerModel model)
public void Apply(ControllerModel model)
{
foreach (var action in model.Actions)
{
if (action.AttributeRouteModel == null)
{
action.AttributeRouteModel = new ReflectedAttributeRouteModel();
action.AttributeRouteModel = new AttributeRouteModel();
}
if (action.AttributeRouteModel.Name == null)

View File

@ -7,11 +7,11 @@ using System.Reflection;
using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedActionModel
public class ActionModel
{
public ReflectedActionModel([NotNull] MethodInfo actionMethod)
public ActionModel([NotNull] MethodInfo actionMethod)
{
ActionMethod = actionMethod;
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
ActionConstraints = new List<IActionConstraintMetadata>();
Filters = new List<IFilter>();
HttpMethods = new List<string>();
Parameters = new List<ReflectedParameterModel>();
Parameters = new List<ParameterModel>();
}
public List<IActionConstraintMetadata> ActionConstraints { get; private set; }
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public List<object> Attributes { get; private set; }
public ReflectedControllerModel Controller { get; set; }
public ControllerModel Controller { get; set; }
public List<IFilter> Filters { get; private set; }
@ -38,20 +38,20 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public bool IsActionNameMatchRequired { get; set; }
public List<ReflectedParameterModel> Parameters { get; private set; }
public List<ParameterModel> Parameters { get; private set; }
public ReflectedAttributeRouteModel AttributeRouteModel { get; set; }
public AttributeRouteModel AttributeRouteModel { get; set; }
/// <summary>
/// If <c>true</c>, <see cref="ApiDescription"/> objects will be created for this action. If <c>null</c>
/// then the value of <see cref="ReflectedControllerModel.ApiExplorerIsVisible"/> will be used.
/// then the value of <see cref="ControllerModel.ApiExplorerIsVisible"/> will be used.
/// </summary>
public bool? ApiExplorerIsVisible { get; set; }
/// <summary>
/// The value for <see cref="ApiDescription.GroupName"/> of <see cref="ApiDescription"/> objects created
/// for actions defined by this controller. If <c>null</c> then the value of
/// <see cref="ReflectedControllerModel.ApiExplorerGroupName"/> will be used.
/// <see cref="ControllerModel.ApiExplorerGroupName"/> will be used.
/// </summary>
public string ApiExplorerGroupName { get; set; }
}

View File

@ -7,17 +7,17 @@ using System.Text;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Routing;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedAttributeRouteModel
public class AttributeRouteModel
{
private static readonly ReflectedAttributeRouteModel _default = new ReflectedAttributeRouteModel();
private static readonly AttributeRouteModel _default = new AttributeRouteModel();
public ReflectedAttributeRouteModel()
public AttributeRouteModel()
{
}
public ReflectedAttributeRouteModel([NotNull] IRouteTemplateProvider templateProvider)
public AttributeRouteModel([NotNull] IRouteTemplateProvider templateProvider)
{
Attribute = templateProvider;
Template = templateProvider.Template;
@ -43,17 +43,17 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
}
/// <summary>
/// Combines two <see cref="ReflectedAttributeRouteModel"/> instances and returns
/// a new <see cref="ReflectedAttributeRouteModel"/> instance with the result.
/// Combines two <see cref="AttributeRouteModel"/> instances and returns
/// a new <see cref="AttributeRouteModel"/> instance with the result.
/// </summary>
/// <param name="left">The left <see cref="ReflectedAttributeRouteModel"/>.</param>
/// <param name="right">The right <see cref="ReflectedAttributeRouteModel"/>.</param>
/// <returns>A new instance of <see cref="ReflectedAttributeRouteModel"/> that represents the
/// combination of the two <see cref="ReflectedAttributeRouteModel"/> instances or <c>null</c> if both
/// <param name="left">The left <see cref="AttributeRouteModel"/>.</param>
/// <param name="right">The right <see cref="AttributeRouteModel"/>.</param>
/// <returns>A new instance of <see cref="AttributeRouteModel"/> that represents the
/// combination of the two <see cref="AttributeRouteModel"/> instances or <c>null</c> if both
/// parameters are <c>null</c>.</returns>
public static ReflectedAttributeRouteModel CombineReflectedAttributeRouteModel(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right)
public static AttributeRouteModel CombineAttributeRouteModel(
AttributeRouteModel left,
AttributeRouteModel right)
{
right = right ?? _default;
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
return null;
}
return new ReflectedAttributeRouteModel()
return new AttributeRouteModel()
{
Template = combinedTemplate,
Order = right.Order ?? left.Order,
@ -81,8 +81,8 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
}
private static string ChooseName(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right)
AttributeRouteModel left,
AttributeRouteModel right)
{
if (right.Name == null && string.IsNullOrEmpty(right.Template))
{

View File

@ -5,17 +5,17 @@ using System;
using System.Collections.Generic;
using System.Reflection;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedControllerModel
public class ControllerModel
{
public ReflectedControllerModel([NotNull] TypeInfo controllerType)
public ControllerModel([NotNull] TypeInfo controllerType)
{
ControllerType = controllerType;
Actions = new List<ReflectedActionModel>();
Actions = new List<ActionModel>();
Attributes = new List<object>();
AttributeRoutes = new List<ReflectedAttributeRouteModel>();
AttributeRoutes = new List<AttributeRouteModel>();
ActionConstraints = new List<IActionConstraintMetadata>();
Filters = new List<IFilter>();
RouteConstraints = new List<RouteConstraintAttribute>();
@ -23,9 +23,9 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public List<IActionConstraintMetadata> ActionConstraints { get; private set; }
public List<ReflectedActionModel> Actions { get; private set; }
public List<ActionModel> Actions { get; private set; }
public ReflectedApplicationModel Application { get; set; }
public GlobalModel Application { get; set; }
public List<object> Attributes { get; private set; }
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public List<RouteConstraintAttribute> RouteConstraints { get; private set; }
public List<ReflectedAttributeRouteModel> AttributeRoutes { get; private set; }
public List<AttributeRouteModel> AttributeRoutes { get; private set; }
/// <summary>
/// If <c>true</c>, <see cref="Description.ApiDescription"/> objects will be created for actions defined by

View File

@ -3,17 +3,17 @@
using System.Collections.Generic;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedApplicationModel
public class GlobalModel
{
public ReflectedApplicationModel()
public GlobalModel()
{
Controllers = new List<ReflectedControllerModel>();
Controllers = new List<ControllerModel>();
Filters = new List<IFilter>();
}
public List<ReflectedControllerModel> Controllers { get; private set; }
public List<ControllerModel> Controllers { get; private set; }
public List<IFilter> Filters { get; private set; }
}

View File

@ -0,0 +1,25 @@
// 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.
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
/// <summary>
/// Allows customization of the of the <see cref="ActionModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on an action method.
///
/// <see cref="IActionModelConvention"/> customizations run after
/// <see cref="IActionModelConvention"/> customications and before
/// <see cref="IParameterModelConvention"/> customizations.
/// </remarks>
public interface IActionModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ActionModel"/>.
/// </summary>
/// <param name="model">The <see cref="ActionModel"/>.</param>
void Apply([NotNull] ActionModel model);
}
}

View File

@ -0,0 +1,25 @@
// 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.
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
/// <summary>
/// Allows customization of the of the <see cref="ControllerModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on a controller class.
///
/// <see cref="IControllerModelConvention"/> customizations run after
/// <see cref="IGlobalModelConvention"/> customizations and before
/// <see cref="IActionModelConvention"/> customizations.
/// </remarks>
public interface IControllerModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ControllerModel"/>.
/// </summary>
/// <param name="model">The <see cref="ControllerModel"/>.</param>
void Apply([NotNull] ControllerModel model);
}
}

View File

@ -0,0 +1,24 @@
// 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.
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
/// <summary>
/// Allows customization of the of the <see cref="GlobalModel"/>.
/// </summary>
/// <remarks>
/// Implementaions of this interface can be registered in <see cref="MvcOptions.ApplicationModelConventions"/>
/// to customize metadata about the application.
///
/// <see cref="IGlobalModelConvention"/> run before other types of customizations to the
/// reflected model.
/// </remarks>
public interface IGlobalModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="GlobalModel"/>.
/// </summary>
/// <param name="model">The <see cref="GlobalModel"/>.</param>
void Apply([NotNull] GlobalModel model);
}
}

View File

@ -0,0 +1,24 @@
// 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.
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
/// <summary>
/// Allows customization of the of the <see cref="ControllerModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on an action method parameter.
///
/// <see cref="IParameterModelConvention"/> customizations run after
/// <see cref="IActionModelConvention"/> customizations.
/// </remarks>
public interface IParameterModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ParameterModel"/>.
/// </summary>
/// <param name="model">The <see cref="ParameterModel"/>.</param>
void Apply([NotNull] ParameterModel model);
}
}

View File

@ -4,18 +4,18 @@
using System.Collections.Generic;
using System.Reflection;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedParameterModel
public class ParameterModel
{
public ReflectedParameterModel(ParameterInfo parameterInfo)
public ParameterModel(ParameterInfo parameterInfo)
{
ParameterInfo = parameterInfo;
Attributes = new List<object>();
}
public ReflectedActionModel Action { get; set; }
public ActionModel Action { get; set; }
public List<object> Attributes { get; private set; }

View File

@ -8,7 +8,7 @@ using System.Reflection;
namespace Microsoft.AspNet.Mvc
{
[DebuggerDisplay("CA {DisplayName}(RC-{RouteConstraints.Count})")]
public class ReflectedActionDescriptor : ActionDescriptor
public class ControllerActionDescriptor : ActionDescriptor
{
public string ControllerName
{

View File

@ -8,14 +8,14 @@ using System.Reflection;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Routing;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc
{
public class ReflectedActionDescriptorProvider : IActionDescriptorProvider
public class ControllerActionDescriptorProvider : IActionDescriptorProvider
{
/// <summary>
/// Represents the default order associated with this provider for dependency injection
@ -30,9 +30,9 @@ namespace Microsoft.AspNet.Mvc
private readonly IControllerAssemblyProvider _controllerAssemblyProvider;
private readonly IActionDiscoveryConventions _conventions;
private readonly IReadOnlyList<IFilter> _globalFilters;
private readonly IEnumerable<IReflectedApplicationModelConvention> _modelConventions;
private readonly IEnumerable<IGlobalModelConvention> _modelConventions;
public ReflectedActionDescriptorProvider(IControllerAssemblyProvider controllerAssemblyProvider,
public ControllerActionDescriptorProvider(IControllerAssemblyProvider controllerAssemblyProvider,
IActionDiscoveryConventions conventions,
IGlobalFilterProvider globalFilters,
IOptionsAccessor<MvcOptions> optionsAccessor)
@ -54,16 +54,16 @@ namespace Microsoft.AspNet.Mvc
callNext();
}
public IEnumerable<ReflectedActionDescriptor> GetDescriptors()
public IEnumerable<ControllerActionDescriptor> GetDescriptors()
{
var model = BuildModel();
ApplyConventions(model);
return Build(model);
}
public ReflectedApplicationModel BuildModel()
public GlobalModel BuildModel()
{
var applicationModel = new ReflectedApplicationModel();
var applicationModel = new GlobalModel();
applicationModel.Filters.AddRange(_globalFilters);
var assemblies = _controllerAssemblyProvider.CandidateAssemblies;
@ -100,11 +100,11 @@ namespace Microsoft.AspNet.Mvc
return applicationModel;
}
private ReflectedControllerModel CreateControllerModel(
ReflectedApplicationModel applicationModel,
private ControllerModel CreateControllerModel(
GlobalModel applicationModel,
TypeInfo controllerType)
{
var controllerModel = new ReflectedControllerModel(controllerType)
var controllerModel = new ControllerModel(controllerType)
{
Application = applicationModel,
};
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Mvc
controllerModel.RouteConstraints.AddRange(attributes.OfType<RouteConstraintAttribute>());
controllerModel.AttributeRoutes.AddRange(
attributes.OfType<IRouteTemplateProvider>().Select(rtp => new ReflectedAttributeRouteModel(rtp)));
attributes.OfType<IRouteTemplateProvider>().Select(rtp => new AttributeRouteModel(rtp)));
var apiVisibility = attributes.OfType<IApiDescriptionVisibilityProvider>().FirstOrDefault();
if (apiVisibility != null)
@ -141,12 +141,12 @@ namespace Microsoft.AspNet.Mvc
return controllerModel;
}
private ReflectedActionModel CreateActionModel(
ReflectedControllerModel controllerModel,
private ActionModel CreateActionModel(
ControllerModel controllerModel,
MethodInfo methodInfo,
ActionInfo actionInfo)
{
var actionModel = new ReflectedActionModel(methodInfo)
var actionModel = new ActionModel(methodInfo)
{
ActionName = actionInfo.ActionName,
Controller = controllerModel,
@ -176,18 +176,18 @@ namespace Microsoft.AspNet.Mvc
if (actionInfo.AttributeRoute != null)
{
actionModel.AttributeRouteModel = new ReflectedAttributeRouteModel(
actionModel.AttributeRouteModel = new AttributeRouteModel(
actionInfo.AttributeRoute);
}
return actionModel;
}
private ReflectedParameterModel CreateParameterModel(
ReflectedActionModel actionModel,
private ParameterModel CreateParameterModel(
ActionModel actionModel,
ParameterInfo parameterInfo)
{
var parameterModel = new ReflectedParameterModel(parameterInfo)
var parameterModel = new ParameterModel(parameterInfo)
{
Action = actionModel,
};
@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Mvc
return parameterModel;
}
public void ApplyConventions(ReflectedApplicationModel model)
public void ApplyConventions(GlobalModel model)
{
// Conventions are applied from the outside-in to allow for scenarios where an action overrides
// a controller, etc.
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc
// while iterating it.
var controllerConventions =
controller.Attributes
.OfType<IReflectedControllerModelConvention>()
.OfType<IControllerModelConvention>()
.ToArray();
foreach (var controllerConvention in controllerConventions)
@ -233,7 +233,7 @@ namespace Microsoft.AspNet.Mvc
// while iterating it.
var actionConventions =
action.Attributes
.OfType<IReflectedActionModelConvention>()
.OfType<IActionModelConvention>()
.ToArray();
foreach (var actionConvention in actionConventions)
@ -247,7 +247,7 @@ namespace Microsoft.AspNet.Mvc
// while iterating it.
var parameterConventions =
parameter.Attributes
.OfType<IReflectedParameterModelConvention>()
.OfType<IParameterModelConvention>()
.ToArray();
foreach (var parameterConvention in parameterConventions)
@ -259,9 +259,9 @@ namespace Microsoft.AspNet.Mvc
}
}
public List<ReflectedActionDescriptor> Build(ReflectedApplicationModel application)
public List<ControllerActionDescriptor> Build(GlobalModel application)
{
var actions = new List<ReflectedActionDescriptor>();
var actions = new List<ControllerActionDescriptor>();
var hasAttributeRoutes = false;
var removalConstraints = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
@ -407,12 +407,12 @@ namespace Microsoft.AspNet.Mvc
return actions;
}
private static IList<ReflectedActionDescriptor> CreateActionDescriptors(
ReflectedApplicationModel application,
ReflectedControllerModel controller,
ReflectedActionModel action)
private static IList<ControllerActionDescriptor> CreateActionDescriptors(
GlobalModel application,
ControllerModel controller,
ActionModel action)
{
var actionDescriptors = new List<ReflectedActionDescriptor>();
var actionDescriptors = new List<ControllerActionDescriptor>();
// We check the action to see if the template allows combination behavior
// (It doesn't start with / or ~/) so that in the case where we have multiple
@ -478,9 +478,9 @@ namespace Microsoft.AspNet.Mvc
return actionDescriptors;
}
private static ReflectedActionDescriptor CreateActionDescriptor(
ReflectedActionModel action,
ReflectedAttributeRouteModel controllerAttributeRoute)
private static ControllerActionDescriptor CreateActionDescriptor(
ActionModel action,
AttributeRouteModel controllerAttributeRoute)
{
var parameterDescriptors = new List<ParameterDescriptor>();
foreach (var parameter in action.Parameters)
@ -493,7 +493,7 @@ namespace Microsoft.AspNet.Mvc
action.AttributeRouteModel,
controllerAttributeRoute);
var actionDescriptor = new ReflectedActionDescriptor()
var actionDescriptor = new ControllerActionDescriptor()
{
Name = action.ActionName,
MethodInfo = action.ActionMethod,
@ -510,7 +510,7 @@ namespace Microsoft.AspNet.Mvc
return actionDescriptor;
}
private static ParameterDescriptor CreateParameterDescriptor(ReflectedParameterModel parameter)
private static ParameterDescriptor CreateParameterDescriptor(ParameterModel parameter)
{
var parameterDescriptor = new ParameterDescriptor()
{
@ -535,9 +535,9 @@ namespace Microsoft.AspNet.Mvc
}
private static void AddApiExplorerInfo(
ReflectedActionDescriptor actionDescriptor,
ReflectedActionModel action,
ReflectedControllerModel controller)
ControllerActionDescriptor actionDescriptor,
ActionModel action,
ControllerModel controller)
{
var apiExplorerIsVisible = action.ApiExplorerIsVisible ?? controller.ApiExplorerIsVisible ?? false;
if (apiExplorerIsVisible)
@ -552,7 +552,7 @@ namespace Microsoft.AspNet.Mvc
}
private static void AddActionFilters(
ReflectedActionDescriptor actionDescriptor,
ControllerActionDescriptor actionDescriptor,
IEnumerable<IFilter> actionFilters,
IEnumerable<IFilter> controllerFilters,
IEnumerable<IFilter> globalFilters)
@ -566,10 +566,10 @@ namespace Microsoft.AspNet.Mvc
}
private static AttributeRouteInfo CreateAttributeRouteInfo(
ReflectedAttributeRouteModel action,
ReflectedAttributeRouteModel controller)
AttributeRouteModel action,
AttributeRouteModel controller)
{
var combinedRoute = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(
var combinedRoute = AttributeRouteModel.CombineAttributeRouteModel(
controller,
action);
@ -589,8 +589,8 @@ namespace Microsoft.AspNet.Mvc
}
private static void AddActionConstraints(
ReflectedActionDescriptor actionDescriptor,
ReflectedActionModel action,
ControllerActionDescriptor actionDescriptor,
ActionModel action,
IEnumerable<IActionConstraintMetadata> controllerConstraints)
{
var constraints = new List<IActionConstraintMetadata>();
@ -618,9 +618,9 @@ namespace Microsoft.AspNet.Mvc
}
public void AddRouteConstraints(
ReflectedActionDescriptor actionDescriptor,
ReflectedControllerModel controller,
ReflectedActionModel action)
ControllerActionDescriptor actionDescriptor,
ControllerModel controller,
ActionModel action)
{
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(
"controller",
@ -641,7 +641,7 @@ namespace Microsoft.AspNet.Mvc
}
private static void AddControllerRouteConstraints(
ReflectedActionDescriptor actionDescriptor,
ControllerActionDescriptor actionDescriptor,
IList<RouteConstraintAttribute> routeconstraints,
ISet<string> removalConstraints)
{
@ -682,7 +682,7 @@ namespace Microsoft.AspNet.Mvc
rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
}
private static void ReplaceRouteConstraints(ReflectedActionDescriptor actionDescriptor)
private static void ReplaceRouteConstraints(ControllerActionDescriptor actionDescriptor)
{
var routeGroupValue = GetRouteGroupValue(
actionDescriptor.AttributeRouteInfo.Order,
@ -697,12 +697,12 @@ namespace Microsoft.AspNet.Mvc
}
private static void ReplaceAttributeRouteTokens(
ReflectedActionDescriptor actionDescriptor,
ControllerActionDescriptor actionDescriptor,
IList<string> routeTemplateErrors)
{
try
{
actionDescriptor.AttributeRouteInfo.Template = ReflectedAttributeRouteModel.ReplaceTokens(
actionDescriptor.AttributeRouteInfo.Template = AttributeRouteModel.ReplaceTokens(
actionDescriptor.AttributeRouteInfo.Template,
actionDescriptor.RouteValueDefaults);
}
@ -717,7 +717,7 @@ namespace Microsoft.AspNet.Mvc
}
}
private static void AddConstraintsAsDefaultRouteValues(ReflectedActionDescriptor actionDescriptor)
private static void AddConstraintsAsDefaultRouteValues(ControllerActionDescriptor actionDescriptor)
{
foreach (var constraint in actionDescriptor.RouteConstraints)
{
@ -732,7 +732,7 @@ namespace Microsoft.AspNet.Mvc
}
private static void AddRemovalConstraints(
ReflectedActionDescriptor actionDescriptor,
ControllerActionDescriptor actionDescriptor,
ISet<string> removalConstraints)
{
foreach (var key in removalConstraints)
@ -749,7 +749,7 @@ namespace Microsoft.AspNet.Mvc
private static void AddActionToNamedGroup(
IDictionary<string, IList<ActionDescriptor>> actionsByRouteName,
string routeName,
ReflectedActionDescriptor actionDescriptor)
ControllerActionDescriptor actionDescriptor)
{
IList<ActionDescriptor> namedActionGroup;
@ -765,7 +765,7 @@ namespace Microsoft.AspNet.Mvc
}
}
private static bool IsAttributeRoutedAction(ReflectedActionDescriptor actionDescriptor)
private static bool IsAttributeRoutedAction(ControllerActionDescriptor actionDescriptor)
{
return actionDescriptor.AttributeRouteInfo != null &&
actionDescriptor.AttributeRouteInfo.Template != null;
@ -829,8 +829,8 @@ namespace Microsoft.AspNet.Mvc
}
private void ValidateActionGroupConfiguration(
IDictionary<MethodInfo, IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>> methodMap,
ReflectedActionDescriptor actionDescriptor,
IDictionary<MethodInfo, IDictionary<ActionModel, IList<ControllerActionDescriptor>>> methodMap,
ControllerActionDescriptor actionDescriptor,
IDictionary<MethodInfo, string> routingConfigurationErrors)
{
string combinedErrorMessage = null;
@ -838,7 +838,7 @@ namespace Microsoft.AspNet.Mvc
var hasAttributeRoutedActions = false;
var hasConventionallyRoutedActions = false;
var invalidHttpMethodActions = new Dictionary<ReflectedActionModel, IEnumerable<string>>();
var invalidHttpMethodActions = new Dictionary<ActionModel, IEnumerable<string>>();
var actionsForMethod = methodMap[actionDescriptor.MethodInfo];
foreach (var reflectedAction in actionsForMethod)
@ -895,8 +895,8 @@ namespace Microsoft.AspNet.Mvc
}
private static void ValidateActionHttpMethodProviders(
ReflectedActionModel reflectedAction,
IDictionary<ReflectedActionModel, IEnumerable<string>> invalidHttpMethodActions)
ActionModel reflectedAction,
IDictionary<ActionModel, IEnumerable<string>> invalidHttpMethodActions)
{
var invalidHttpMethodProviderAttributes = reflectedAction.Attributes
.Where(attr => attr is IActionHttpMethodProvider &&
@ -929,9 +929,9 @@ namespace Microsoft.AspNet.Mvc
}
private static string CreateInvalidActionHttpMethodProviderErrorMessage(
ReflectedActionDescriptor actionDescriptor,
IDictionary<ReflectedActionModel, IEnumerable<string>> invalidHttpMethodActions,
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod)
ControllerActionDescriptor actionDescriptor,
IDictionary<ActionModel, IEnumerable<string>> invalidHttpMethodActions,
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod)
{
var messagesForMethodInfo = new List<string>();
foreach (var invalidAction in invalidHttpMethodActions)
@ -981,8 +981,8 @@ namespace Microsoft.AspNet.Mvc
}
private static string CreateMixedRoutedActionDescriptorsErrorMessage(
ReflectedActionDescriptor actionDescriptor,
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod)
ControllerActionDescriptor actionDescriptor,
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod)
{
// Text to show as the attribute route template for conventionally routed actions.
var nullTemplate = Resources.AttributeRoute_NullTemplateRepresentation;
@ -1044,12 +1044,12 @@ namespace Microsoft.AspNet.Mvc
// public ActionResult List(){ ... }
// }
private class MethodToActionMap :
Dictionary<MethodInfo, IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>>
Dictionary<MethodInfo, IDictionary<ActionModel, IList<ControllerActionDescriptor>>>
{
public void AddToMethodInfo(ReflectedActionModel action,
IList<ReflectedActionDescriptor> actionDescriptors)
public void AddToMethodInfo(ActionModel action,
IList<ControllerActionDescriptor> actionDescriptors)
{
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod = null;
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod = null;
if (TryGetValue(action.ActionMethod, out actionsForMethod))
{
actionsForMethod.Add(action, actionDescriptors);
@ -1057,7 +1057,7 @@ namespace Microsoft.AspNet.Mvc
else
{
var reflectedActionMap =
new Dictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>();
new Dictionary<ActionModel, IList<ControllerActionDescriptor>>();
reflectedActionMap.Add(action, actionDescriptors);
Add(action.ActionMethod, reflectedActionMap);
}

View File

@ -11,10 +11,10 @@ using Microsoft.AspNet.Mvc.Core;
namespace Microsoft.AspNet.Mvc
{
public static class ReflectedActionExecutor
public static class ControllerActionExecutor
{
private static readonly MethodInfo _convertOfTMethod =
typeof(ReflectedActionExecutor).GetRuntimeMethods().Single(methodInfo => methodInfo.Name == "Convert");
typeof(ControllerActionExecutor).GetRuntimeMethods().Single(methodInfo => methodInfo.Name == "Convert");
// Method called via reflection.
private static Task<object> Convert<T>(object taskAsObject)

View File

@ -10,17 +10,17 @@ using Microsoft.Framework.DependencyInjection;
namespace Microsoft.AspNet.Mvc
{
public class ReflectedActionInvoker : FilterActionInvoker
public class ControllerActionInvoker : FilterActionInvoker
{
private readonly ReflectedActionDescriptor _descriptor;
private readonly ControllerActionDescriptor _descriptor;
private readonly IControllerFactory _controllerFactory;
private readonly IInputFormattersProvider _inputFormattersProvider;
public ReflectedActionInvoker([NotNull] ActionContext actionContext,
public ControllerActionInvoker([NotNull] ActionContext actionContext,
[NotNull] IActionBindingContextProvider bindingContextProvider,
[NotNull] INestedProviderManager<FilterProviderContext> filterProvider,
[NotNull] IControllerFactory controllerFactory,
[NotNull] ReflectedActionDescriptor descriptor,
[NotNull] ControllerActionDescriptor descriptor,
[NotNull] IInputFormattersProvider inputFormattersProvider,
[NotNull] IBodyModelValidator modelValidator)
: base(actionContext, bindingContextProvider, filterProvider, modelValidator)
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc
{
throw new ArgumentException(
Resources.FormatPropertyOfTypeCannotBeNull("MethodInfo",
typeof(ReflectedActionDescriptor)),
typeof(ControllerActionDescriptor)),
"descriptor");
}
}
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc
protected override async Task<IActionResult> InvokeActionAsync(ActionExecutingContext actionExecutingContext)
{
var actionMethodInfo = _descriptor.MethodInfo;
var actionReturnValue = await ReflectedActionExecutor.ExecuteAsync(
var actionReturnValue = await ControllerActionExecutor.ExecuteAsync(
actionMethodInfo,
ActionContext.Controller,
actionExecutingContext.ActionArguments);

View File

@ -7,7 +7,7 @@ using Microsoft.Framework.DependencyInjection;
namespace Microsoft.AspNet.Mvc
{
public class ReflectedActionInvokerProvider : IActionInvokerProvider
public class ControllerActionInvokerProvider : IActionInvokerProvider
{
private readonly IControllerFactory _controllerFactory;
private readonly IActionBindingContextProvider _bindingProvider;
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc
private readonly INestedProviderManager<FilterProviderContext> _filterProvider;
private readonly IBodyModelValidator _modelValidator;
public ReflectedActionInvokerProvider(IControllerFactory controllerFactory,
public ControllerActionInvokerProvider(IControllerFactory controllerFactory,
IActionBindingContextProvider bindingProvider,
IInputFormattersProvider inputFormattersProvider,
INestedProviderManager<FilterProviderContext> filterProvider,
@ -35,11 +35,11 @@ namespace Microsoft.AspNet.Mvc
public void Invoke(ActionInvokerProviderContext context, Action callNext)
{
var actionDescriptor = context.ActionContext.ActionDescriptor as ReflectedActionDescriptor;
var actionDescriptor = context.ActionContext.ActionDescriptor as ControllerActionDescriptor;
if (actionDescriptor != null)
{
context.Result = new ReflectedActionInvoker(
context.Result = new ControllerActionInvoker(
context.ActionContext,
_bindingProvider,
_filterProvider,

View File

@ -24,12 +24,12 @@ namespace Microsoft.AspNet.Mvc
public object CreateController(ActionContext actionContext)
{
var actionDescriptor = actionContext.ActionDescriptor as ReflectedActionDescriptor;
var actionDescriptor = actionContext.ActionDescriptor as ControllerActionDescriptor;
if (actionDescriptor == null)
{
throw new ArgumentException(
Resources.FormatDefaultControllerFactory_ActionDescriptorMustBeReflected(
typeof(ReflectedActionDescriptor)),
typeof(ControllerActionDescriptor)),
"actionContext");
}

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.Description
{
/// <summary>
/// Implements a provider of <see cref="ApiDescription"/> for actions represented
/// by <see cref="ReflectedActionDescriptor"/>.
/// by <see cref="ControllerActionDescriptor"/>.
/// </summary>
public class DefaultApiDescriptionProvider : INestedProvider<ApiDescriptionProviderContext>
{
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.Description
/// <inheritdoc />
public void Invoke(ApiDescriptionProviderContext context, Action callNext)
{
foreach (var action in context.Actions.OfType<ReflectedActionDescriptor>())
foreach (var action in context.Actions.OfType<ControllerActionDescriptor>())
{
var extensionData = action.GetProperty<ApiDescriptionActionData>();
if (extensionData != null)
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.Description
}
private ApiDescription CreateApiDescription(
ReflectedActionDescriptor action,
ControllerActionDescriptor action,
string httpMethod,
string groupName)
{
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Description
return apiDescription;
}
private IEnumerable<string> GetHttpMethods(ReflectedActionDescriptor action)
private IEnumerable<string> GetHttpMethods(ControllerActionDescriptor action)
{
if (action.ActionConstraints != null && action.ActionConstraints.Count > 0)
{
@ -129,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.Description
}
}
private string GetRelativePath(ReflectedActionDescriptor action)
private string GetRelativePath(ControllerActionDescriptor action)
{
// This is a placeholder for functionality which will correctly generate the relative path
// stub of an action. See: #885
@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.Description
}
private IReadOnlyList<ApiResponseFormat> GetResponseFormats(
ReflectedActionDescriptor action,
ControllerActionDescriptor action,
IApiResponseMetadataProvider[] responseMetadataAttributes,
Type declaredType,
Type runtimeType)
@ -221,7 +221,7 @@ namespace Microsoft.AspNet.Mvc.Description
return results;
}
private Type GetDeclaredReturnType(ReflectedActionDescriptor action)
private Type GetDeclaredReturnType(ControllerActionDescriptor action)
{
var declaredReturnType = action.MethodInfo.ReturnType;
if (declaredReturnType == typeof(void) ||
@ -281,7 +281,7 @@ namespace Microsoft.AspNet.Mvc.Description
return declaredReturnType;
}
private IApiResponseMetadataProvider[] GetResponseMetadataAttributes(ReflectedActionDescriptor action)
private IApiResponseMetadataProvider[] GetResponseMetadataAttributes(ControllerActionDescriptor action)
{
if (action.FilterDescriptors == null)
{

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.OptionDescriptors;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace Microsoft.AspNet.Mvc
{
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc
public MvcOptions()
{
ApplicationModelConventions = new List<IReflectedApplicationModelConvention>();
ApplicationModelConventions = new List<IGlobalModelConvention>();
ModelBinders = new List<ModelBinderDescriptor>();
ViewEngines = new List<ViewEngineDescriptor>();
ValueProviderFactories = new List<ValueProviderFactoryDescriptor>();
@ -113,6 +113,6 @@ namespace Microsoft.AspNet.Mvc
/// </summary>
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
public List<IReflectedApplicationModelConvention> ApplicationModelConventions { get; private set; }
public List<IGlobalModelConvention> ApplicationModelConventions { get; private set; }
}
}

View File

@ -1,25 +0,0 @@
// 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.
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
{
/// <summary>
/// Allows customization of the of the <see cref="ReflectedActionModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on an action method.
///
/// <see cref="IReflectedActionModelConvention"/> customizations run after
/// <see cref="IReflectedActionModelConvention"/> customications and before
/// <see cref="IReflectedParameterModelConvention"/> customizations.
/// </remarks>
public interface IReflectedActionModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ReflectedActionModel"/>.
/// </summary>
/// <param name="model">The <see cref="ReflectedActionModel"/>.</param>
void Apply([NotNull] ReflectedActionModel model);
}
}

View File

@ -1,24 +0,0 @@
// 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.
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
{
/// <summary>
/// Allows customization of the of the <see cref="ReflectedApplicationModel"/>.
/// </summary>
/// <remarks>
/// Implementaions of this interface can be registered in <see cref="MvcOptions.ApplicationModelConventions"/>
/// to customize metadata about the application.
///
/// <see cref="IReflectedApplicationModelConvention"/> run before other types of customizations to the
/// reflected model.
/// </remarks>
public interface IReflectedApplicationModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ReflectedApplicationModel"/>.
/// </summary>
/// <param name="model">The <see cref="ReflectedApplicationModel"/>.</param>
void Apply([NotNull] ReflectedApplicationModel model);
}
}

View File

@ -1,25 +0,0 @@
// 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.
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
{
/// <summary>
/// Allows customization of the of the <see cref="ReflectedControllerModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on a controller class.
///
/// <see cref="IReflectedControllerModelConvention"/> customizations run after
/// <see cref="IReflectedApplicationModelConvention"/> customizations and before
/// <see cref="IReflectedActionModelConvention"/> customizations.
/// </remarks>
public interface IReflectedControllerModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ReflectedControllerModel"/>.
/// </summary>
/// <param name="model">The <see cref="ReflectedControllerModel"/>.</param>
void Apply([NotNull] ReflectedControllerModel model);
}
}

View File

@ -1,24 +0,0 @@
// 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.
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
{
/// <summary>
/// Allows customization of the of the <see cref="ReflectedControllerModel"/>.
/// </summary>
/// <remarks>
/// To use this interface, create an <see cref="System.Attribute"/> class which implements the interface and
/// place it on an action method parameter.
///
/// <see cref="IReflectedParameterModelConvention"/> customizations run after
/// <see cref="IReflectedActionModelConvention"/> customizations.
/// </remarks>
public interface IReflectedParameterModelConvention
{
/// <summary>
/// Called to apply the convention to the <see cref="ReflectedParameterModel"/>.
/// </summary>
/// <param name="model">The <see cref="ReflectedParameterModel"/>.</param>
void Apply([NotNull] ReflectedParameterModel model);
}
}

View File

@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Mvc
{
var component = CreateComponent(context);
var result = await ReflectedActionExecutor.ExecuteAsync(method, component, _args);
var result = await ControllerActionExecutor.ExecuteAsync(method, component, _args);
return CoerceToViewComponentResult(result);
}

View File

@ -72,9 +72,9 @@ namespace Microsoft.AspNet.Mvc
yield return describe.Singleton<IFileInfoCache, ExpiringFileInfoCache>();
yield return describe.Transient<INestedProvider<ActionDescriptorProviderContext>,
ReflectedActionDescriptorProvider>();
ControllerActionDescriptorProvider>();
yield return describe.Transient<INestedProvider<ActionInvokerProviderContext>,
ReflectedActionInvokerProvider>();
ControllerActionInvokerProvider>();
yield return describe.Singleton<IActionDescriptorsCollectionProvider,
DefaultActionDescriptorsCollectionProvider>();

View File

@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc
// Act
var result = actionDescriptorProvider.GetDescriptors()
.Select(x => x as ReflectedActionDescriptor)
.Select(x => x as ControllerActionDescriptor)
.FirstOrDefault(
x=> x.ControllerName == "NonAction" &&
x.Name == actionName);
@ -193,7 +193,7 @@ namespace Microsoft.AspNet.Mvc
return await defaultActionSelector.SelectAsync(context);
}
private ReflectedActionDescriptorProvider GetActionDescriptorProvider(
private ControllerActionDescriptorProvider GetActionDescriptorProvider(
IActionDiscoveryConventions actionDiscoveryConventions = null)
{
var controllerAssemblyProvider = new StaticControllerAssemblyProvider();
@ -207,7 +207,7 @@ namespace Microsoft.AspNet.Mvc
actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
}
return new ReflectedActionDescriptorProvider(
return new ControllerActionDescriptorProvider(
controllerAssemblyProvider,
actionDiscoveryConventions,
new TestGlobalFilterProvider(),

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
public async Task AsyncAction_WithVoidReturnType()
{
var methodWithVoidReturnType = new MethodWithVoidReturnType(TestController.VoidAction);
var result = await ReflectedActionExecutor.ExecuteAsync(
var result = await ControllerActionExecutor.ExecuteAsync(
methodWithVoidReturnType.GetMethodInfo(),
null,
(IDictionary<string, object>)null);
@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction);
var result = await ReflectedActionExecutor.ExecuteAsync(
var result = await ControllerActionExecutor.ExecuteAsync(
methodWithTaskReturnType.GetMethodInfo(),
_controller,
actionParameters);
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
var result = await ReflectedActionExecutor.ExecuteAsync(
var result = await ControllerActionExecutor.ExecuteAsync(
methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters);
@ -80,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
var methodWithTaskOfTaskOfIntReturnType = new MethodWithTaskOfTaskOfIntReturnType(_controller.TaskOfTaskAction);
var result = await (Task<int>)(await ReflectedActionExecutor.ExecuteAsync(
var result = await (Task<int>)(await ControllerActionExecutor.ExecuteAsync(
methodWithTaskOfTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters));
@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
// Act and Assert
await Assert.ThrowsAsync<NotImplementedException>(
() => ReflectedActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
() => ControllerActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters));
}
@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionWithExceptionWithoutAsync);
await Assert.ThrowsAsync<NotImplementedException>(
() => ReflectedActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
() => ControllerActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters));
}
@ -127,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionThrowAfterAwait);
await AssertThrowsAsync<ArgumentException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters),
@ -139,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
{
string inputString = "hello";
var syncMethod = new SyncMethod(_controller.Echo);
var result = await ReflectedActionExecutor.ExecuteAsync(
var result = await ControllerActionExecutor.ExecuteAsync(
syncMethod.GetMethodInfo(),
_controller,
new Dictionary<string, object>() { { "input", inputString } });
@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
string inputString = "hello";
var syncMethod = new SyncMethod(_controller.EchoWithException);
await Assert.ThrowsAsync<NotImplementedException>(
() => ReflectedActionExecutor.ExecuteAsync(
() => ControllerActionExecutor.ExecuteAsync(
syncMethod.GetMethodInfo(),
_controller,
new Dictionary<string, object>() { { "input", inputString } }));
@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
typeof(TestController));
await AssertThrowsAsync<InvalidOperationException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
methodWithCutomTaskReturnType.GetMethodInfo(),
_controller,
actionParameters),
@ -196,7 +196,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
await AssertThrowsAsync<InvalidOperationException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
methodWithCutomTaskOfTReturnType.GetMethodInfo(),
_controller,
actionParameters),
@ -213,7 +213,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask);
await AssertThrowsAsync<InvalidOperationException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
methodWithUnwrappedTask.GetMethodInfo(),
_controller,
actionParameters),
@ -238,7 +238,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
typeof(TestController));
await AssertThrowsAsync<InvalidOperationException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
dynamicTaskMethod.GetMethodInfo(),
_controller,
actionParameters),
@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var actionParameters = new Dictionary<string, object> { { "s", inputParam2 }, { "i", inputParam1 } };
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
var result = await ReflectedActionExecutor.ExecuteAsync(
var result = await ControllerActionExecutor.ExecuteAsync(
methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters);
@ -280,7 +280,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
// If it is an unrecognized derived type we throw an InvalidOperationException.
await AssertThrowsAsync<ArgumentException>(
async () =>
await ReflectedActionExecutor.ExecuteAsync(
await ControllerActionExecutor.ExecuteAsync(
methodWithTaskOfIntReturnType.GetMethodInfo(),
_controller,
actionParameters),

View File

@ -6,9 +6,9 @@ using System;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
namespace Microsoft.AspNet.Mvc.ApplicationModel
{
public class ReflectedAttributeRouteModelTests
public class AttributeRouteModelTests
{
[Theory]
[InlineData(null, null, null)]
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public void Combine_EmptyTemplates(string left, string right, string expected)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
var combined = AttributeRouteModel.CombineTemplates(left, right);
// Assert
Assert.Equal(expected, combined);
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public void Combine_OneTemplateHasValue(string left, string right, string expected)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
var combined = AttributeRouteModel.CombineTemplates(left, right);
// Assert
Assert.Equal(expected, combined);
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public void Combine_BothTemplatesHasValue(string left, string right, string expected)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
var combined = AttributeRouteModel.CombineTemplates(left, right);
// Assert
Assert.Equal(expected, combined);
@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
public void Combine_InvalidTemplates(string left, string right, string expected)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
var combined = AttributeRouteModel.CombineTemplates(left, right);
// Assert
Assert.Equal(expected, combined);
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
}
// Act
var result = ReflectedAttributeRouteModel.ReplaceTokens(template, valuesDictionary);
var result = AttributeRouteModel.ReplaceTokens(template, valuesDictionary);
// Assert
Assert.Equal(expected, result);
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
// Act
var ex = Assert.Throws<InvalidOperationException>(
() => { ReflectedAttributeRouteModel.ReplaceTokens(template, valuesDictionary); });
() => { AttributeRouteModel.ReplaceTokens(template, valuesDictionary); });
// Assert
Assert.Equal(expected, ex.Message);
@ -162,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
// Act
var ex = Assert.Throws<InvalidOperationException>(
() => { ReflectedAttributeRouteModel.ReplaceTokens(template, values); });
() => { AttributeRouteModel.ReplaceTokens(template, values); });
// Assert
Assert.Equal(expected, ex.Message);
@ -171,12 +171,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
[Theory]
[MemberData(nameof(CombineOrdersTestData))]
public void Combine_Orders(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right,
AttributeRouteModel left,
AttributeRouteModel right,
int? expected)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
// Assert
Assert.NotNull(combined);
@ -186,12 +186,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
[Theory]
[MemberData(nameof(ValidReflectedAttributeRouteModelsTestData))]
public void Combine_ValidReflectedAttributeRouteModels(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right,
ReflectedAttributeRouteModel expectedResult)
AttributeRouteModel left,
AttributeRouteModel right,
AttributeRouteModel expectedResult)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
// Assert
Assert.NotNull(combined);
@ -201,11 +201,11 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
[Theory]
[MemberData(nameof(NullOrNullTemplateReflectedAttributeRouteModelTestData))]
public void Combine_NullOrNullTemplateReflectedAttributeRouteModels(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right)
AttributeRouteModel left,
AttributeRouteModel right)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
// Assert
Assert.Null(combined);
@ -214,14 +214,14 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
[Theory]
[MemberData(nameof(RightOverridesReflectedAttributeRouteModelTestData))]
public void Combine_RightOverridesReflectedAttributeRouteModel(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right)
AttributeRouteModel left,
AttributeRouteModel right)
{
// Arrange
var expectedTemplate = ReflectedAttributeRouteModel.CombineTemplates(null, right.Template);
var expectedTemplate = AttributeRouteModel.CombineTemplates(null, right.Template);
// Act
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
// Assert
Assert.NotNull(combined);
@ -232,12 +232,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
[Theory]
[MemberData(nameof(CombineNamesTestData))]
public void Combine_Names(
ReflectedAttributeRouteModel left,
ReflectedAttributeRouteModel right,
AttributeRouteModel left,
AttributeRouteModel right,
string expectedName)
{
// Arrange & Act
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
// Assert
Assert.NotNull(combined);
@ -249,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
get
{
// AttributeRoute on the controller, attribute route on the action, expected name.
var data = new TheoryData<ReflectedAttributeRouteModel, ReflectedAttributeRouteModel, string>();
var data = new TheoryData<AttributeRouteModel, AttributeRouteModel, string>();
// Combined name is null if no name is provided.
data.Add(Create(template: "/", order: null, name: null), null, null);
@ -302,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
get
{
// AttributeRoute on the controller, attribute route on the action, expected order.
var data = new TheoryData<ReflectedAttributeRouteModel, ReflectedAttributeRouteModel, int?>();
var data = new TheoryData<AttributeRouteModel, AttributeRouteModel, int?>();
data.Add(Create("", order: 1), Create("", order: 2), 2);
data.Add(Create("", order: 1), Create("", order: null), 1);
@ -331,7 +331,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
get
{
// AttributeRoute on the controller, attribute route on the action.
var data = new TheoryData<ReflectedAttributeRouteModel, ReflectedAttributeRouteModel>();
var data = new TheoryData<AttributeRouteModel, AttributeRouteModel>();
var leftModel = Create("Home", order: 3);
data.Add(leftModel, Create("/"));
@ -350,7 +350,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
get
{
// AttributeRoute on the controller, attribute route on the action.
var data = new TheoryData<ReflectedAttributeRouteModel, ReflectedAttributeRouteModel>();
var data = new TheoryData<AttributeRouteModel, AttributeRouteModel>();
data.Add(null, null);
data.Add(null, Create(null));
@ -366,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
get
{
// AttributeRoute on the controller, attribute route on the action, expected combined attribute route.
var data = new TheoryData<ReflectedAttributeRouteModel, ReflectedAttributeRouteModel, ReflectedAttributeRouteModel>();
var data = new TheoryData<AttributeRouteModel, AttributeRouteModel, AttributeRouteModel>();
data.Add(null, Create("Index"), Create("Index"));
data.Add(Create(null), Create("Index"), Create("Index"));
data.Add(Create("Home"), null, Create("Home"));
@ -524,9 +524,9 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
}
}
private static ReflectedAttributeRouteModel Create(string template, int? order = null, string name = null)
private static AttributeRouteModel Create(string template, int? order = null, string name = null)
{
return new ReflectedAttributeRouteModel
return new AttributeRouteModel
{
Template = template,
Order = order,

View File

@ -7,14 +7,14 @@ using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
using Microsoft.Framework.OptionsModel;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Mvc.Test
{
public class ReflectedActionDescriptorProviderTests
public class ControllerActionDescriptorProviderTests
{
[Fact]
public void GetDescriptors_GetsDescriptorsOnlyForValidActions()
@ -85,18 +85,18 @@ namespace Microsoft.AspNet.Mvc.Test
"The following errors occurred with attribute routing information:" + Environment.NewLine +
Environment.NewLine +
"Error 1:" + Environment.NewLine +
"A method 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"A method 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeRoutedHttpMethodController.PutOrPatch'" +
" that defines attribute routed actions must not have attributes that implement " +
"'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement " +
"'Microsoft.AspNet.Mvc.Routing.IRouteTemplateProvider':" + Environment.NewLine +
"Action 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeRoutedHttpMethodController.PutOrPatch' with route template 'Products' has " +
"'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
"'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
" invalid 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' attributes." + Environment.NewLine +
"Action 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeRoutedHttpMethodController.PutOrPatch' with route template 'Items' has " +
"'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
"'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
" invalid 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' attributes.";
var provider = GetProvider(
@ -466,7 +466,7 @@ namespace Microsoft.AspNet.Mvc.Test
}
[Fact]
public void BuildModel_CreatesReflectedControllerModels_ForAllControllers()
public void BuildModel_CreatesControllerModels_ForAllControllers()
{
// Arrange
var provider = GetProvider(
@ -502,7 +502,7 @@ namespace Microsoft.AspNet.Mvc.Test
}
[Fact]
public void BuildModel_CreatesReflectedActionDescriptors_ForValidActions()
public void BuildModel_CreatesControllerActionDescriptors_ForValidActions()
{
// Arrange
var provider = GetProvider(
@ -539,8 +539,8 @@ namespace Microsoft.AspNet.Mvc.Test
Assert.Equal(
new[]
{
"Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+PersonController.GetPerson",
"Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+PersonController.ListPeople",
"Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+PersonController.GetPerson",
"Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+PersonController.ListPeople",
},
displayNames);
}
@ -587,13 +587,13 @@ namespace Microsoft.AspNet.Mvc.Test
"The following errors occurred with attribute routing information:" + Environment.NewLine +
Environment.NewLine +
"Error 1:" + Environment.NewLine +
"For action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"For action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"MultipleErrorsController.Unknown'" + Environment.NewLine +
"Error: While processing template 'stub/[action]/[unknown]', a replacement value for the token 'unknown' " +
"could not be found. Available tokens: 'controller, action'." + Environment.NewLine +
Environment.NewLine +
"Error 2:" + Environment.NewLine +
"For action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"For action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"MultipleErrorsController.Invalid'" + Environment.NewLine +
"Error: The route template '[invalid/syntax' has invalid syntax. A replacement token is not closed.";
@ -786,22 +786,22 @@ namespace Microsoft.AspNet.Mvc.Test
"The following errors occurred with attribute routing information:" + Environment.NewLine +
Environment.NewLine +
"Error 1:" + Environment.NewLine +
"A method 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"A method 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method'" +
" must not define attribute routed actions and non attribute routed actions at the same time:" + Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: 'AttributeRouted'" + Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: '(none)'" + Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: '(none)'" + Environment.NewLine +
"A method 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"A method 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' that defines attribute routed actions must not" +
" have attributes that implement 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement" +
" 'Microsoft.AspNet.Mvc.Routing.IRouteTemplateProvider':" + Environment.NewLine +
"Action 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' with route template 'AttributeRouted' has " +
"'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
"'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+CustomHttpMethodConstraintAttribute'" +
" invalid 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' attributes.";
var provider = GetProvider(
@ -847,37 +847,37 @@ namespace Microsoft.AspNet.Mvc.Test
"Error 1:" + Environment.NewLine +
"Attribute routes with the same name 'Products' must have the same template:"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.Get' - Template: 'Products'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.Get' - Template: 'Products/{id}'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.Put' - Template: 'Products/{id}'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.Post' - Template: 'Products'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.Delete' - Template: 'Products/{id}'"
+ Environment.NewLine + Environment.NewLine +
"Error 2:" + Environment.NewLine +
"Attribute routes with the same name 'Items' must have the same template:"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.GetItems' - Template: 'Items/{id}'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.PostItems' - Template: 'Items'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.PutItems' - Template: 'Items/{id}'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.DeleteItems' - Template: 'Items/{id}'"
+ Environment.NewLine +
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
"SameNameDifferentTemplatesController.PatchItems' - Template: 'Items'";
// Act
@ -1142,24 +1142,24 @@ namespace Microsoft.AspNet.Mvc.Test
// Arrange
var sequence = 0;
var applicationConvention = new Mock<IReflectedApplicationModelConvention>();
var applicationConvention = new Mock<IGlobalModelConvention>();
applicationConvention
.Setup(c => c.Apply(It.IsAny<ReflectedApplicationModel>()))
.Setup(c => c.Apply(It.IsAny<GlobalModel>()))
.Callback(() => { Assert.Equal(0, sequence++); });
var controllerConvention = new Mock<IReflectedControllerModelConvention>();
var controllerConvention = new Mock<IControllerModelConvention>();
controllerConvention
.Setup(c => c.Apply(It.IsAny<ReflectedControllerModel>()))
.Setup(c => c.Apply(It.IsAny<ControllerModel>()))
.Callback(() => { Assert.Equal(1, sequence++); });
var actionConvention = new Mock<IReflectedActionModelConvention>();
var actionConvention = new Mock<IActionModelConvention>();
actionConvention
.Setup(c => c.Apply(It.IsAny<ReflectedActionModel>()))
.Setup(c => c.Apply(It.IsAny<ActionModel>()))
.Callback(() => { Assert.Equal(2, sequence++); });
var parameterConvention = new Mock<IReflectedParameterModelConvention>();
var parameterConvention = new Mock<IParameterModelConvention>();
parameterConvention
.Setup(c => c.Apply(It.IsAny<ReflectedParameterModel>()))
.Setup(c => c.Apply(It.IsAny<ParameterModel>()))
.Callback(() => { Assert.Equal(3, sequence++); });
var options = new MockMvcOptionsAccessor();
@ -1328,7 +1328,7 @@ namespace Microsoft.AspNet.Mvc.Test
Assert.Single(action.ActionConstraints, a => a is ConstraintAttribute);
}
private ReflectedActionDescriptorProvider GetProvider(
private ControllerActionDescriptorProvider GetProvider(
TypeInfo controllerTypeInfo,
IEnumerable<IFilter> filters = null)
{
@ -1339,7 +1339,7 @@ namespace Microsoft.AspNet.Mvc.Test
.SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { controllerTypeInfo.Assembly });
var provider = new ReflectedActionDescriptorProvider(
var provider = new ControllerActionDescriptorProvider(
assemblyProvider.Object,
conventions,
new TestGlobalFilterProvider(filters),
@ -1348,7 +1348,7 @@ namespace Microsoft.AspNet.Mvc.Test
return provider;
}
private ReflectedActionDescriptorProvider GetProvider(
private ControllerActionDescriptorProvider GetProvider(
params TypeInfo[] controllerTypeInfo)
{
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo);
@ -1358,7 +1358,7 @@ namespace Microsoft.AspNet.Mvc.Test
.SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { controllerTypeInfo.First().Assembly });
var provider = new ReflectedActionDescriptorProvider(
var provider = new ControllerActionDescriptorProvider(
assemblyProvider.Object,
conventions,
new TestGlobalFilterProvider(),
@ -1367,7 +1367,7 @@ namespace Microsoft.AspNet.Mvc.Test
return provider;
}
private ReflectedActionDescriptorProvider GetProvider(
private ControllerActionDescriptorProvider GetProvider(
TypeInfo type,
IOptionsAccessor<MvcOptions> options)
{
@ -1378,7 +1378,7 @@ namespace Microsoft.AspNet.Mvc.Test
.SetupGet(ap => ap.CandidateAssemblies)
.Returns(new Assembly[] { type.Assembly });
return new ReflectedActionDescriptorProvider(
return new ControllerActionDescriptorProvider(
assemblyProvider.Object,
conventions,
new TestGlobalFilterProvider(),
@ -1394,7 +1394,7 @@ namespace Microsoft.AspNet.Mvc.Test
.SetupGet(ap => ap.CandidateAssemblies)
.Returns(controllerTypeInfos.Select(cti => cti.Assembly).Distinct());
var provider = new ReflectedActionDescriptorProvider(
var provider = new ControllerActionDescriptorProvider(
assemblyProvider.Object,
conventions,
new TestGlobalFilterProvider(),

View File

@ -18,7 +18,7 @@ using Xunit;
namespace Microsoft.AspNet.Mvc
{
public class ReflectedActionInvokerTest
public class ControllerActionInvokerTest
{
// Intentionally choosing an uncommon exception type.
private readonly Exception _actionException = new TimeZoneNotFoundException();
@ -1212,7 +1212,7 @@ namespace Microsoft.AspNet.Mvc
var mockActionResult = new Mock<IActionResult>();
// Assert
var result = ReflectedActionInvoker.CreateActionResult(
var result = ControllerActionInvoker.CreateActionResult(
mockActionResult.Object.GetType(), mockActionResult.Object);
// Act
@ -1225,7 +1225,7 @@ namespace Microsoft.AspNet.Mvc
{
// Arrange, Act & Assert
ExceptionAssert.Throws<InvalidOperationException>(
() => ReflectedActionInvoker.CreateActionResult(typeof(IActionResult), null),
() => ControllerActionInvoker.CreateActionResult(typeof(IActionResult), null),
"Cannot return null from an action method with a return type of '"
+ typeof(IActionResult)
+ "'.");
@ -1237,7 +1237,7 @@ namespace Microsoft.AspNet.Mvc
public void CreateActionResult_Types_ReturnsObjectResultForTaskAndVoidReturnTypes(Type type)
{
// Arrange & Act
var result = ReflectedActionInvoker.CreateActionResult(type, null);
var result = ControllerActionInvoker.CreateActionResult(type, null);
// Assert
var objectResult = Assert.IsType<ObjectResult>(result);
@ -1269,21 +1269,21 @@ namespace Microsoft.AspNet.Mvc
public void CreateActionResult_ReturnsObjectContentResult(Type type, object input)
{
// Arrange & Act
var actualResult = ReflectedActionInvoker.CreateActionResult(type, input);
var actualResult = ControllerActionInvoker.CreateActionResult(type, input);
// Assert
var contentResult = Assert.IsType<ObjectResult>(actualResult);
Assert.Same(input, contentResult.Value);
}
private TestReflectedActionInvoker CreateInvoker(IFilter filter, bool actionThrows = false)
private TestControllerActionInvoker CreateInvoker(IFilter filter, bool actionThrows = false)
{
return CreateInvoker(new[] { filter }, actionThrows);
}
private TestReflectedActionInvoker CreateInvoker(IFilter[] filters, bool actionThrows = false)
private TestControllerActionInvoker CreateInvoker(IFilter[] filters, bool actionThrows = false)
{
var actionDescriptor = new ReflectedActionDescriptor()
var actionDescriptor = new ControllerActionDescriptor()
{
FilterDescriptors = new List<FilterDescriptor>(),
Parameters = new List<ParameterDescriptor>(),
@ -1291,11 +1291,11 @@ namespace Microsoft.AspNet.Mvc
if (actionThrows)
{
actionDescriptor.MethodInfo = typeof(ReflectedActionInvokerTest).GetMethod("ThrowingActionMethod");
actionDescriptor.MethodInfo = typeof(ControllerActionInvokerTest).GetMethod("ThrowingActionMethod");
}
else
{
actionDescriptor.MethodInfo = typeof(ReflectedActionInvokerTest).GetMethod("ActionMethod");
actionDescriptor.MethodInfo = typeof(ControllerActionInvokerTest).GetMethod("ActionMethod");
}
var httpContext = new Mock<HttpContext>(MockBehavior.Loose);
@ -1339,7 +1339,7 @@ namespace Microsoft.AspNet.Mvc
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
var invoker = new TestReflectedActionInvoker(
var invoker = new TestControllerActionInvoker(
actionContext,
actionBindingContextProvider.Object,
filterProvider.Object,
@ -1356,7 +1356,7 @@ namespace Microsoft.AspNet.Mvc
{
// Arrange
Func<object, int> method = x => 1;
var actionDescriptor = new ReflectedActionDescriptor
var actionDescriptor = new ControllerActionDescriptor
{
MethodInfo = method.Method,
Parameters = new List<ParameterDescriptor>
@ -1386,7 +1386,7 @@ namespace Microsoft.AspNet.Mvc
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
var invoker = new ReflectedActionInvoker(actionContext,
var invoker = new ControllerActionInvoker(actionContext,
actionBindingContextProvider.Object,
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
Mock.Of<IControllerFactory>(),
@ -1408,7 +1408,7 @@ namespace Microsoft.AspNet.Mvc
{
// Arrange
Func<object, int> method = x => 1;
var actionDescriptor = new ReflectedActionDescriptor
var actionDescriptor = new ControllerActionDescriptor
{
MethodInfo = method.Method,
Parameters = new List<ParameterDescriptor>
@ -1446,7 +1446,7 @@ namespace Microsoft.AspNet.Mvc
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
var invoker = new ReflectedActionInvoker(actionContext,
var invoker = new ControllerActionInvoker(actionContext,
actionBindingContextProvider.Object,
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
Mock.Of<IControllerFactory>(),
@ -1467,7 +1467,7 @@ namespace Microsoft.AspNet.Mvc
[Fact]
public async Task GetActionArguments_NoInputFormatterFound_SetsModelStateError()
{
var actionDescriptor = new ReflectedActionDescriptor
var actionDescriptor = new ControllerActionDescriptor
{
MethodInfo = typeof(TestController).GetTypeInfo().GetMethod("ActionMethodWithDefaultValues"),
Parameters = new List<ParameterDescriptor>
@ -1501,7 +1501,7 @@ namespace Microsoft.AspNet.Mvc
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
var invoker = new ReflectedActionInvoker(actionContext,
var invoker = new ControllerActionInvoker(actionContext,
actionBindingContextProvider.Object,
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
controllerFactory.Object,
@ -1527,7 +1527,7 @@ namespace Microsoft.AspNet.Mvc
public async Task Invoke_UsesDefaultValuesIfNotBound()
{
// Arrange
var actionDescriptor = new ReflectedActionDescriptor
var actionDescriptor = new ControllerActionDescriptor
{
MethodInfo = typeof(TestController).GetTypeInfo()
.DeclaredMethods
@ -1569,7 +1569,7 @@ namespace Microsoft.AspNet.Mvc
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
var invoker = new ReflectedActionInvoker(actionContext,
var invoker = new ControllerActionInvoker(actionContext,
actionBindingContextProvider.Object,
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
controllerFactory.Object,
@ -1625,16 +1625,16 @@ namespace Microsoft.AspNet.Mvc
}
}
public class TestReflectedActionInvoker : ReflectedActionInvoker
public class TestControllerActionInvoker : ControllerActionInvoker
{
private Mock<IControllerFactory> _factoryMock;
public TestReflectedActionInvoker(
public TestControllerActionInvoker(
ActionContext actionContext,
IActionBindingContextProvider bindingContextProvider,
INestedProviderManager<FilterProviderContext> filterProvider,
Mock<IControllerFactory> controllerFactoryMock,
ReflectedActionDescriptor descriptor,
ControllerActionDescriptor descriptor,
IInputFormattersProvider inputFormattersProvider,
IBodyModelValidator bodyModelValidator) :
base(actionContext,

View File

@ -97,12 +97,12 @@ namespace Microsoft.AspNet.Mvc
return await defaultActionSelector.SelectAsync(context);
}
private ReflectedActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions)
private ControllerActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions)
{
var assemblies = new Assembly[] { typeof(DefaultActionDiscoveryConventionsActionSelectionTests).GetTypeInfo().Assembly, };
var controllerAssemblyProvider = new Mock<IControllerAssemblyProvider>();
controllerAssemblyProvider.SetupGet(x => x.CandidateAssemblies).Returns(assemblies);
return new ReflectedActionDescriptorProvider(
return new ControllerActionDescriptorProvider(
controllerAssemblyProvider.Object,
actionDiscoveryConventions,
new TestGlobalFilterProvider(),

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.Description
public void GetApiDescription_IgnoresActionWithoutApiExplorerData()
{
// Arrange
var action = new ReflectedActionDescriptor();
var action = new ControllerActionDescriptor();
// Act
var descriptions = GetApiDescriptions(action);
@ -387,9 +387,9 @@ namespace Microsoft.AspNet.Mvc.Description
return formatters;
}
private ReflectedActionDescriptor CreateActionDescriptor(string methodName = null)
private ControllerActionDescriptor CreateActionDescriptor(string methodName = null)
{
var action = new ReflectedActionDescriptor();
var action = new ControllerActionDescriptor();
action.SetProperty(new ApiDescriptionActionData());
action.MethodInfo = GetType().GetMethod(

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Person><Name>" + sampleName + "</Name></Person>";
var modelStateDictionary = new ModelStateDictionary();
var invoker = GetReflectedActionInvoker(
var invoker = GetControllerActionInvoker(
input, typeof(Person), new XmlSerializerInputFormatter(), "application/xml");
// Act
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<User><Name>" + sampleName + "</Name><UserName>" + sampleUserName + "</UserName></User>";
var modelStateDictionary = new ModelStateDictionary();
var invoker = GetReflectedActionInvoker(input, typeof(User), new XmlSerializerInputFormatter(), "application/xml");
var invoker = GetControllerActionInvoker(input, typeof(User), new XmlSerializerInputFormatter(), "application/xml");
// Act
var result = await invoker.GetActionArguments(modelStateDictionary);
@ -76,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
var modelStateDictionary = new ModelStateDictionary();
var invoker = GetReflectedActionInvoker(input, typeof(Customers), new JsonInputFormatter(), "application/xml");
var invoker = GetControllerActionInvoker(input, typeof(Customers), new JsonInputFormatter(), "application/xml");
// Act
var result = await invoker.GetActionArguments(modelStateDictionary);
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
var modelStateDictionary = new ModelStateDictionary();
var invoker = GetReflectedActionInvoker(input, typeof(Customers), new JsonInputFormatter(), "application/xml");
var invoker = GetControllerActionInvoker(input, typeof(Customers), new JsonInputFormatter(), "application/xml");
// Act
var result = await invoker.GetActionArguments(modelStateDictionary);
@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
Assert.Equal(sampleSecondUserName, model.Users[1].UserName);
}
private static ReflectedActionInvoker GetReflectedActionInvoker(
private static ControllerActionInvoker GetControllerActionInvoker(
string input, Type parameterType, IInputFormatter selectedFormatter, string contentType)
{
var mvcOptions = new MvcOptions();
@ -139,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
accessor.Object, Mock.Of<ITypeActivator>(), Mock.Of<IServiceProvider>());
Func<object, int> method = x => 1;
var actionDescriptor = new ReflectedActionDescriptor
var actionDescriptor = new ControllerActionDescriptor
{
MethodInfo = method.Method,
Parameters = new List<ParameterDescriptor>
@ -173,7 +173,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
inputFormattersProvider.SetupGet(o => o.InputFormatters)
.Returns(new List<IInputFormatter>());
return new ReflectedActionInvoker(actionContext,
return new ControllerActionInvoker(actionContext,
actionBindingContextProvider.Object,
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
Mock.Of<IControllerFactory>(),

View File

@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Mvc.Routing
var controllerType = typeof(HomeController);
var actionMethod = controllerType.GetMethod("Index");
var action = new ReflectedActionDescriptor();
var action = new ControllerActionDescriptor();
action.DisplayName = "Microsoft.AspNet.Mvc.Routing.AttributeRoutingTest+HomeController.Index";
action.MethodInfo = actionMethod;
action.RouteConstraints = new List<RouteDataActionConstraint>()

View File

@ -10,10 +10,10 @@ using System.Net;
namespace Microsoft.AspNet.Mvc.FunctionalTests
{
public class ReflectedModelTest
public class ApplicationModelTest
{
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ReflectedModelWebSite));
private readonly Action<IApplicationBuilder> _app = new ReflectedModelWebSite.Startup().Configure;
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ApplicationModelWebSite));
private readonly Action<IApplicationBuilder> _app = new ApplicationModelWebSite.Startup().Configure;
[Fact]
public async Task ControllerModel_CustomizedWithAttribute()
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var client = server.CreateClient();
// Act
var response = await client.GetAsync("http://localhost/ReflectedActionModel/ActionName");
var response = await client.GetAsync("http://localhost/ActionModel/ActionName");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var client = server.CreateClient();
// Act
var response = await client.GetAsync("http://localhost/ReflectedParameterModel/GetParameterIsOptional");
var response = await client.GetAsync("http://localhost/ParameterModel/GetParameterIsOptional");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

View File

@ -7,6 +7,7 @@
"AddServicesWebSite": "1.0.0",
"AntiForgeryWebSite": "1.0.0",
"ApiExplorerWebSite": "1.0.0",
"ApplicationModelWebSite": "1.0.0",
"BasicWebSite": "1.0.0",
"CompositeViewEngine": "1.0.0",
"ConnegWebSite": "1.0.0",
@ -17,7 +18,6 @@
"VersioningWebSite": "1.0.0",
"ModelBindingWebSite": "1.0.0",
"MvcSample.Web": "1.0.0",
"ReflectedModelWebSite": "1.0.0",
"RoutingWebSite": "1.0.0",
"RazorWebSite": "1.0.0",
"RazorInstrumentationWebsite": "1.0.0",

View File

@ -3,14 +3,14 @@
using System;
using System.Reflection;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace ApiExplorer
{
// Disables ApiExplorer for a specific controller type.
// This is part of the test that validates that ApiExplorer can be configured via
// convention
public class ApiExplorerVisibilityDisabledConvention : IReflectedApplicationModelConvention
public class ApiExplorerVisibilityDisabledConvention : IGlobalModelConvention
{
private readonly TypeInfo _type;
@ -19,7 +19,7 @@ namespace ApiExplorer
_type = type.GetTypeInfo();
}
public void Apply(ReflectedApplicationModel model)
public void Apply(GlobalModel model)
{
foreach (var controller in model.Controllers)
{

View File

@ -1,16 +1,16 @@
// 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.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace ApiExplorer
{
// Enables ApiExplorer for controllers that haven't explicitly configured it.
// This is part of the test that validates that ApiExplorer can be configured via
// convention
public class ApiExplorerVisibilityEnabledConvention : IReflectedApplicationModelConvention
public class ApiExplorerVisibilityEnabledConvention : IGlobalModelConvention
{
public void Apply(ReflectedApplicationModel model)
public void Apply(GlobalModel model)
{
foreach (var controller in model.Controllers)
{

View File

@ -6,7 +6,7 @@
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>c2ef54f8-8886-4260-a322-44f76245f95d</ProjectGuid>
<ProjectGuid>cae52cb7-0fac-4b5b-8251-b0ff837db657</ProjectGuid>
<OutputType>Web</OutputType>
<RootNamespace>ReflectedModelWebSite</RootNamespace>
</PropertyGroup>

View File

@ -3,23 +3,23 @@
using System;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace ReflectedModelWebSite
namespace ApplicationModelWebSite
{
// This controller uses an reflected model attribute to change an action name, and thus
// the URL.
public class ReflectedActionModelController : Controller
public class ActionModelController : Controller
{
[ActionName2("ActionName")]
public string GetActionName()
{
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
return actionDescriptor.Name;
}
private class ActionName2Attribute : Attribute, IReflectedActionModelConvention
private class ActionName2Attribute : Attribute, IActionModelConvention
{
private readonly string _actionName;
@ -28,7 +28,7 @@ namespace ReflectedModelWebSite
_actionName = actionName;
}
public void Apply(ReflectedActionModel model)
public void Apply(ActionModel model)
{
model.ActionName = _actionName;
}

View File

@ -3,23 +3,23 @@
using System;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace ReflectedModelWebSite
namespace ApplicationModelWebSite
{
// This controller uses an reflected model attribute to change the controller name, and thus
// the URL.
[ControllerName("CoolController")]
public class ReflectedControllerModelController : Controller
public class ControllerModelController : Controller
{
public string GetControllerName()
{
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
return actionDescriptor.ControllerName;
}
private class ControllerNameAttribute : Attribute, IReflectedControllerModelConvention
private class ControllerNameAttribute : Attribute, IControllerModelConvention
{
private readonly string _controllerName;
@ -28,7 +28,7 @@ namespace ReflectedModelWebSite
_controllerName = controllerName;
}
public void Apply(ReflectedControllerModel model)
public void Apply(ControllerModel model)
{
model.ControllerName = _controllerName;
}

View File

@ -3,23 +3,23 @@
using System;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
using Microsoft.AspNet.Mvc.ApplicationModel;
namespace ReflectedModelWebSite
namespace ApplicationModelWebSite
{
// This controller uses an reflected model attribute to change a parameter to optional.
public class ReflectedParameterModelController : Controller
public class ParameterModelController : Controller
{
public string GetParameterIsOptional([Optional] int? id)
{
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
return actionDescriptor.Parameters[0].IsOptional.ToString();
}
private class OptionalAttribute : Attribute, IReflectedParameterModelConvention
private class OptionalAttribute : Attribute, IParameterModelConvention
{
public void Apply(ReflectedParameterModel model)
public void Apply(ParameterModel model)
{
model.IsOptional = true;
}

View File

@ -4,7 +4,7 @@
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
namespace ReflectedModelWebSite
namespace ApplicationModelWebSite
{
public class Startup
{

View File

@ -22,7 +22,7 @@ namespace BasicWebSite
{
get
{
return ReflectedActionDescriptorProvider.DefaultOrder - 100;
return ControllerActionDescriptorProvider.DefaultOrder - 100;
}
}

View File

@ -47,7 +47,7 @@ namespace RoutingWebSite
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
action = _actionContext.ActionDescriptor.Name,
controller = ((ReflectedActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
link,
});

View File

@ -47,7 +47,7 @@ namespace VersioningWebSite
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
action = _actionContext.ActionDescriptor.Name,
controller = ((ReflectedActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
link,
});