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:
parent
144a4b5921
commit
a88f59fc49
51
Mvc.sln
51
Mvc.sln
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.22130.0
|
VisualStudioVersion = 14.0.22013.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
@ -81,14 +81,15 @@ EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UrlHelperWebSite", "test\WebSites\UrlHelperWebSite\UrlHelperWebSite.kproj", "{A192E504-2881-41DC-90D1-B7F1DD1134E8}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UrlHelperWebSite", "test\WebSites\UrlHelperWebSite\UrlHelperWebSite.kproj", "{A192E504-2881-41DC-90D1-B7F1DD1134E8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApiExplorerWebSite", "test\WebSites\ApiExplorerWebSite\ApiExplorerWebSite.kproj", "{61061528-071E-424E-965A-07BCC2F02672}"
|
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
|
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
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FilesWebSite", "test\WebSites\FilesWebSite\FilesWebSite.kproj", "{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FilesWebSite", "test\WebSites\FilesWebSite\FilesWebSite.kproj", "{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorInstrumentationWebSite", "test\WebSites\RazorInstrumentationWebSite\RazorInstrumentationWebSite.kproj", "{2B2B9876-903C-4065-8D62-2EE832BBA106}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorInstrumentationWebSite", "test\WebSites\RazorInstrumentationWebSite\RazorInstrumentationWebSite.kproj", "{2B2B9876-903C-4065-8D62-2EE832BBA106}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationModelWebSite", "test\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.kproj", "{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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.ActiveCfg = Release|Any CPU
|
||||||
{A192E504-2881-41DC-90D1-B7F1DD1134E8}.Release|Mixed Platforms.Build.0 = 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
|
{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.ActiveCfg = Debug|Any CPU
|
||||||
{61061528-071E-424E-965A-07BCC2F02672}.Debug|Any CPU.Build.0 = 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
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{C6304029-78C8-4604-99BE-2078DCA1DD36}.Release|Mixed Platforms.Build.0 = 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
|
{C6304029-78C8-4604-99BE-2078DCA1DD36}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{C2EF54F8-8886-4260-A322-44F76245F95D}.Release|x86.ActiveCfg = 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.ActiveCfg = Debug|Any CPU
|
||||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Any CPU.Build.0 = 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
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Mixed Platforms.Build.0 = 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
|
{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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -507,10 +508,10 @@ Global
|
||||||
{1976AC4A-FEA4-4587-A158-D9F79736D2B6} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
{1976AC4A-FEA4-4587-A158-D9F79736D2B6} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||||
{96107AC0-18E2-474D-BAB4-2FFF2185FBCD} = {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}
|
{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}
|
{61061528-071E-424E-965A-07BCC2F02672} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||||
{C6304029-78C8-4604-99BE-2078DCA1DD36} = {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}
|
{2B2B9876-903C-4065-8D62-2EE832BBA106} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||||
|
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,20 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
|
using Microsoft.AspNet.Mvc.ApplicationModel;
|
||||||
|
|
||||||
namespace MvcSample.Web
|
namespace MvcSample.Web
|
||||||
{
|
{
|
||||||
// Adds an auto-generated route-name to each action in the controller
|
// 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)
|
foreach (var action in model.Actions)
|
||||||
{
|
{
|
||||||
if (action.AttributeRouteModel == null)
|
if (action.AttributeRouteModel == null)
|
||||||
{
|
{
|
||||||
action.AttributeRouteModel = new ReflectedAttributeRouteModel();
|
action.AttributeRouteModel = new AttributeRouteModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.AttributeRouteModel.Name == null)
|
if (action.AttributeRouteModel.Name == null)
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.Description;
|
using Microsoft.AspNet.Mvc.Description;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
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;
|
ActionMethod = actionMethod;
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
ActionConstraints = new List<IActionConstraintMetadata>();
|
ActionConstraints = new List<IActionConstraintMetadata>();
|
||||||
Filters = new List<IFilter>();
|
Filters = new List<IFilter>();
|
||||||
HttpMethods = new List<string>();
|
HttpMethods = new List<string>();
|
||||||
Parameters = new List<ReflectedParameterModel>();
|
Parameters = new List<ParameterModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IActionConstraintMetadata> ActionConstraints { get; private set; }
|
public List<IActionConstraintMetadata> ActionConstraints { get; private set; }
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
|
|
||||||
public List<object> Attributes { get; private set; }
|
public List<object> Attributes { get; private set; }
|
||||||
|
|
||||||
public ReflectedControllerModel Controller { get; set; }
|
public ControllerModel Controller { get; set; }
|
||||||
|
|
||||||
public List<IFilter> Filters { get; private set; }
|
public List<IFilter> Filters { get; private set; }
|
||||||
|
|
||||||
|
|
@ -38,20 +38,20 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
|
|
||||||
public bool IsActionNameMatchRequired { get; set; }
|
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>
|
/// <summary>
|
||||||
/// If <c>true</c>, <see cref="ApiDescription"/> objects will be created for this action. If <c>null</c>
|
/// 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>
|
/// </summary>
|
||||||
public bool? ApiExplorerIsVisible { get; set; }
|
public bool? ApiExplorerIsVisible { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The value for <see cref="ApiDescription.GroupName"/> of <see cref="ApiDescription"/> objects created
|
/// 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
|
/// 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>
|
/// </summary>
|
||||||
public string ApiExplorerGroupName { get; set; }
|
public string ApiExplorerGroupName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -7,17 +7,17 @@ using System.Text;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
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;
|
Attribute = templateProvider;
|
||||||
Template = templateProvider.Template;
|
Template = templateProvider.Template;
|
||||||
|
|
@ -43,17 +43,17 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Combines two <see cref="ReflectedAttributeRouteModel"/> instances and returns
|
/// Combines two <see cref="AttributeRouteModel"/> instances and returns
|
||||||
/// a new <see cref="ReflectedAttributeRouteModel"/> instance with the result.
|
/// a new <see cref="AttributeRouteModel"/> instance with the result.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="left">The left <see cref="ReflectedAttributeRouteModel"/>.</param>
|
/// <param name="left">The left <see cref="AttributeRouteModel"/>.</param>
|
||||||
/// <param name="right">The right <see cref="ReflectedAttributeRouteModel"/>.</param>
|
/// <param name="right">The right <see cref="AttributeRouteModel"/>.</param>
|
||||||
/// <returns>A new instance of <see cref="ReflectedAttributeRouteModel"/> that represents the
|
/// <returns>A new instance of <see cref="AttributeRouteModel"/> that represents the
|
||||||
/// combination of the two <see cref="ReflectedAttributeRouteModel"/> instances or <c>null</c> if both
|
/// combination of the two <see cref="AttributeRouteModel"/> instances or <c>null</c> if both
|
||||||
/// parameters are <c>null</c>.</returns>
|
/// parameters are <c>null</c>.</returns>
|
||||||
public static ReflectedAttributeRouteModel CombineReflectedAttributeRouteModel(
|
public static AttributeRouteModel CombineAttributeRouteModel(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right)
|
AttributeRouteModel right)
|
||||||
{
|
{
|
||||||
right = right ?? _default;
|
right = right ?? _default;
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReflectedAttributeRouteModel()
|
return new AttributeRouteModel()
|
||||||
{
|
{
|
||||||
Template = combinedTemplate,
|
Template = combinedTemplate,
|
||||||
Order = right.Order ?? left.Order,
|
Order = right.Order ?? left.Order,
|
||||||
|
|
@ -81,8 +81,8 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ChooseName(
|
private static string ChooseName(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right)
|
AttributeRouteModel right)
|
||||||
{
|
{
|
||||||
if (right.Name == null && string.IsNullOrEmpty(right.Template))
|
if (right.Name == null && string.IsNullOrEmpty(right.Template))
|
||||||
{
|
{
|
||||||
|
|
@ -5,17 +5,17 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
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;
|
ControllerType = controllerType;
|
||||||
|
|
||||||
Actions = new List<ReflectedActionModel>();
|
Actions = new List<ActionModel>();
|
||||||
Attributes = new List<object>();
|
Attributes = new List<object>();
|
||||||
AttributeRoutes = new List<ReflectedAttributeRouteModel>();
|
AttributeRoutes = new List<AttributeRouteModel>();
|
||||||
ActionConstraints = new List<IActionConstraintMetadata>();
|
ActionConstraints = new List<IActionConstraintMetadata>();
|
||||||
Filters = new List<IFilter>();
|
Filters = new List<IFilter>();
|
||||||
RouteConstraints = new List<RouteConstraintAttribute>();
|
RouteConstraints = new List<RouteConstraintAttribute>();
|
||||||
|
|
@ -23,9 +23,9 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
|
|
||||||
public List<IActionConstraintMetadata> ActionConstraints { get; private set; }
|
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; }
|
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<RouteConstraintAttribute> RouteConstraints { get; private set; }
|
||||||
|
|
||||||
public List<ReflectedAttributeRouteModel> AttributeRoutes { get; private set; }
|
public List<AttributeRouteModel> AttributeRoutes { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If <c>true</c>, <see cref="Description.ApiDescription"/> objects will be created for actions defined by
|
/// If <c>true</c>, <see cref="Description.ApiDescription"/> objects will be created for actions defined by
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
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>();
|
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; }
|
public List<IFilter> Filters { get; private set; }
|
||||||
}
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,18 +4,18 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
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;
|
ParameterInfo = parameterInfo;
|
||||||
|
|
||||||
Attributes = new List<object>();
|
Attributes = new List<object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReflectedActionModel Action { get; set; }
|
public ActionModel Action { get; set; }
|
||||||
|
|
||||||
public List<object> Attributes { get; private set; }
|
public List<object> Attributes { get; private set; }
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Reflection;
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("CA {DisplayName}(RC-{RouteConstraints.Count})")]
|
[DebuggerDisplay("CA {DisplayName}(RC-{RouteConstraints.Count})")]
|
||||||
public class ReflectedActionDescriptor : ActionDescriptor
|
public class ControllerActionDescriptor : ActionDescriptor
|
||||||
{
|
{
|
||||||
public string ControllerName
|
public string ControllerName
|
||||||
{
|
{
|
||||||
|
|
@ -8,14 +8,14 @@ using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
using Microsoft.AspNet.Mvc.Description;
|
using Microsoft.AspNet.Mvc.Description;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
|
using Microsoft.AspNet.Mvc.ApplicationModel;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
using Microsoft.AspNet.Mvc.Routing;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class ReflectedActionDescriptorProvider : IActionDescriptorProvider
|
public class ControllerActionDescriptorProvider : IActionDescriptorProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the default order associated with this provider for dependency injection
|
/// 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 IControllerAssemblyProvider _controllerAssemblyProvider;
|
||||||
private readonly IActionDiscoveryConventions _conventions;
|
private readonly IActionDiscoveryConventions _conventions;
|
||||||
private readonly IReadOnlyList<IFilter> _globalFilters;
|
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,
|
IActionDiscoveryConventions conventions,
|
||||||
IGlobalFilterProvider globalFilters,
|
IGlobalFilterProvider globalFilters,
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor)
|
IOptionsAccessor<MvcOptions> optionsAccessor)
|
||||||
|
|
@ -54,16 +54,16 @@ namespace Microsoft.AspNet.Mvc
|
||||||
callNext();
|
callNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ReflectedActionDescriptor> GetDescriptors()
|
public IEnumerable<ControllerActionDescriptor> GetDescriptors()
|
||||||
{
|
{
|
||||||
var model = BuildModel();
|
var model = BuildModel();
|
||||||
ApplyConventions(model);
|
ApplyConventions(model);
|
||||||
return Build(model);
|
return Build(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReflectedApplicationModel BuildModel()
|
public GlobalModel BuildModel()
|
||||||
{
|
{
|
||||||
var applicationModel = new ReflectedApplicationModel();
|
var applicationModel = new GlobalModel();
|
||||||
applicationModel.Filters.AddRange(_globalFilters);
|
applicationModel.Filters.AddRange(_globalFilters);
|
||||||
|
|
||||||
var assemblies = _controllerAssemblyProvider.CandidateAssemblies;
|
var assemblies = _controllerAssemblyProvider.CandidateAssemblies;
|
||||||
|
|
@ -100,11 +100,11 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return applicationModel;
|
return applicationModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedControllerModel CreateControllerModel(
|
private ControllerModel CreateControllerModel(
|
||||||
ReflectedApplicationModel applicationModel,
|
GlobalModel applicationModel,
|
||||||
TypeInfo controllerType)
|
TypeInfo controllerType)
|
||||||
{
|
{
|
||||||
var controllerModel = new ReflectedControllerModel(controllerType)
|
var controllerModel = new ControllerModel(controllerType)
|
||||||
{
|
{
|
||||||
Application = applicationModel,
|
Application = applicationModel,
|
||||||
};
|
};
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
controllerModel.RouteConstraints.AddRange(attributes.OfType<RouteConstraintAttribute>());
|
controllerModel.RouteConstraints.AddRange(attributes.OfType<RouteConstraintAttribute>());
|
||||||
|
|
||||||
controllerModel.AttributeRoutes.AddRange(
|
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();
|
var apiVisibility = attributes.OfType<IApiDescriptionVisibilityProvider>().FirstOrDefault();
|
||||||
if (apiVisibility != null)
|
if (apiVisibility != null)
|
||||||
|
|
@ -141,12 +141,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return controllerModel;
|
return controllerModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionModel CreateActionModel(
|
private ActionModel CreateActionModel(
|
||||||
ReflectedControllerModel controllerModel,
|
ControllerModel controllerModel,
|
||||||
MethodInfo methodInfo,
|
MethodInfo methodInfo,
|
||||||
ActionInfo actionInfo)
|
ActionInfo actionInfo)
|
||||||
{
|
{
|
||||||
var actionModel = new ReflectedActionModel(methodInfo)
|
var actionModel = new ActionModel(methodInfo)
|
||||||
{
|
{
|
||||||
ActionName = actionInfo.ActionName,
|
ActionName = actionInfo.ActionName,
|
||||||
Controller = controllerModel,
|
Controller = controllerModel,
|
||||||
|
|
@ -176,18 +176,18 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
if (actionInfo.AttributeRoute != null)
|
if (actionInfo.AttributeRoute != null)
|
||||||
{
|
{
|
||||||
actionModel.AttributeRouteModel = new ReflectedAttributeRouteModel(
|
actionModel.AttributeRouteModel = new AttributeRouteModel(
|
||||||
actionInfo.AttributeRoute);
|
actionInfo.AttributeRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actionModel;
|
return actionModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedParameterModel CreateParameterModel(
|
private ParameterModel CreateParameterModel(
|
||||||
ReflectedActionModel actionModel,
|
ActionModel actionModel,
|
||||||
ParameterInfo parameterInfo)
|
ParameterInfo parameterInfo)
|
||||||
{
|
{
|
||||||
var parameterModel = new ReflectedParameterModel(parameterInfo)
|
var parameterModel = new ParameterModel(parameterInfo)
|
||||||
{
|
{
|
||||||
Action = actionModel,
|
Action = actionModel,
|
||||||
};
|
};
|
||||||
|
|
@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return parameterModel;
|
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
|
// Conventions are applied from the outside-in to allow for scenarios where an action overrides
|
||||||
// a controller, etc.
|
// a controller, etc.
|
||||||
|
|
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// while iterating it.
|
// while iterating it.
|
||||||
var controllerConventions =
|
var controllerConventions =
|
||||||
controller.Attributes
|
controller.Attributes
|
||||||
.OfType<IReflectedControllerModelConvention>()
|
.OfType<IControllerModelConvention>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
foreach (var controllerConvention in controllerConventions)
|
foreach (var controllerConvention in controllerConventions)
|
||||||
|
|
@ -233,7 +233,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// while iterating it.
|
// while iterating it.
|
||||||
var actionConventions =
|
var actionConventions =
|
||||||
action.Attributes
|
action.Attributes
|
||||||
.OfType<IReflectedActionModelConvention>()
|
.OfType<IActionModelConvention>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
foreach (var actionConvention in actionConventions)
|
foreach (var actionConvention in actionConventions)
|
||||||
|
|
@ -247,7 +247,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// while iterating it.
|
// while iterating it.
|
||||||
var parameterConventions =
|
var parameterConventions =
|
||||||
parameter.Attributes
|
parameter.Attributes
|
||||||
.OfType<IReflectedParameterModelConvention>()
|
.OfType<IParameterModelConvention>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
foreach (var parameterConvention in parameterConventions)
|
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 hasAttributeRoutes = false;
|
||||||
var removalConstraints = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
var removalConstraints = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
@ -407,12 +407,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IList<ReflectedActionDescriptor> CreateActionDescriptors(
|
private static IList<ControllerActionDescriptor> CreateActionDescriptors(
|
||||||
ReflectedApplicationModel application,
|
GlobalModel application,
|
||||||
ReflectedControllerModel controller,
|
ControllerModel controller,
|
||||||
ReflectedActionModel action)
|
ActionModel action)
|
||||||
{
|
{
|
||||||
var actionDescriptors = new List<ReflectedActionDescriptor>();
|
var actionDescriptors = new List<ControllerActionDescriptor>();
|
||||||
|
|
||||||
// We check the action to see if the template allows combination behavior
|
// 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
|
// (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;
|
return actionDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReflectedActionDescriptor CreateActionDescriptor(
|
private static ControllerActionDescriptor CreateActionDescriptor(
|
||||||
ReflectedActionModel action,
|
ActionModel action,
|
||||||
ReflectedAttributeRouteModel controllerAttributeRoute)
|
AttributeRouteModel controllerAttributeRoute)
|
||||||
{
|
{
|
||||||
var parameterDescriptors = new List<ParameterDescriptor>();
|
var parameterDescriptors = new List<ParameterDescriptor>();
|
||||||
foreach (var parameter in action.Parameters)
|
foreach (var parameter in action.Parameters)
|
||||||
|
|
@ -493,7 +493,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
action.AttributeRouteModel,
|
action.AttributeRouteModel,
|
||||||
controllerAttributeRoute);
|
controllerAttributeRoute);
|
||||||
|
|
||||||
var actionDescriptor = new ReflectedActionDescriptor()
|
var actionDescriptor = new ControllerActionDescriptor()
|
||||||
{
|
{
|
||||||
Name = action.ActionName,
|
Name = action.ActionName,
|
||||||
MethodInfo = action.ActionMethod,
|
MethodInfo = action.ActionMethod,
|
||||||
|
|
@ -510,7 +510,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return actionDescriptor;
|
return actionDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ParameterDescriptor CreateParameterDescriptor(ReflectedParameterModel parameter)
|
private static ParameterDescriptor CreateParameterDescriptor(ParameterModel parameter)
|
||||||
{
|
{
|
||||||
var parameterDescriptor = new ParameterDescriptor()
|
var parameterDescriptor = new ParameterDescriptor()
|
||||||
{
|
{
|
||||||
|
|
@ -535,9 +535,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddApiExplorerInfo(
|
private static void AddApiExplorerInfo(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
ReflectedActionModel action,
|
ActionModel action,
|
||||||
ReflectedControllerModel controller)
|
ControllerModel controller)
|
||||||
{
|
{
|
||||||
var apiExplorerIsVisible = action.ApiExplorerIsVisible ?? controller.ApiExplorerIsVisible ?? false;
|
var apiExplorerIsVisible = action.ApiExplorerIsVisible ?? controller.ApiExplorerIsVisible ?? false;
|
||||||
if (apiExplorerIsVisible)
|
if (apiExplorerIsVisible)
|
||||||
|
|
@ -552,7 +552,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddActionFilters(
|
private static void AddActionFilters(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IEnumerable<IFilter> actionFilters,
|
IEnumerable<IFilter> actionFilters,
|
||||||
IEnumerable<IFilter> controllerFilters,
|
IEnumerable<IFilter> controllerFilters,
|
||||||
IEnumerable<IFilter> globalFilters)
|
IEnumerable<IFilter> globalFilters)
|
||||||
|
|
@ -566,10 +566,10 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AttributeRouteInfo CreateAttributeRouteInfo(
|
private static AttributeRouteInfo CreateAttributeRouteInfo(
|
||||||
ReflectedAttributeRouteModel action,
|
AttributeRouteModel action,
|
||||||
ReflectedAttributeRouteModel controller)
|
AttributeRouteModel controller)
|
||||||
{
|
{
|
||||||
var combinedRoute = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(
|
var combinedRoute = AttributeRouteModel.CombineAttributeRouteModel(
|
||||||
controller,
|
controller,
|
||||||
action);
|
action);
|
||||||
|
|
||||||
|
|
@ -589,8 +589,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddActionConstraints(
|
private static void AddActionConstraints(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
ReflectedActionModel action,
|
ActionModel action,
|
||||||
IEnumerable<IActionConstraintMetadata> controllerConstraints)
|
IEnumerable<IActionConstraintMetadata> controllerConstraints)
|
||||||
{
|
{
|
||||||
var constraints = new List<IActionConstraintMetadata>();
|
var constraints = new List<IActionConstraintMetadata>();
|
||||||
|
|
@ -618,9 +618,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRouteConstraints(
|
public void AddRouteConstraints(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
ReflectedControllerModel controller,
|
ControllerModel controller,
|
||||||
ReflectedActionModel action)
|
ActionModel action)
|
||||||
{
|
{
|
||||||
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(
|
actionDescriptor.RouteConstraints.Add(new RouteDataActionConstraint(
|
||||||
"controller",
|
"controller",
|
||||||
|
|
@ -641,7 +641,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddControllerRouteConstraints(
|
private static void AddControllerRouteConstraints(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IList<RouteConstraintAttribute> routeconstraints,
|
IList<RouteConstraintAttribute> routeconstraints,
|
||||||
ISet<string> removalConstraints)
|
ISet<string> removalConstraints)
|
||||||
{
|
{
|
||||||
|
|
@ -682,7 +682,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReplaceRouteConstraints(ReflectedActionDescriptor actionDescriptor)
|
private static void ReplaceRouteConstraints(ControllerActionDescriptor actionDescriptor)
|
||||||
{
|
{
|
||||||
var routeGroupValue = GetRouteGroupValue(
|
var routeGroupValue = GetRouteGroupValue(
|
||||||
actionDescriptor.AttributeRouteInfo.Order,
|
actionDescriptor.AttributeRouteInfo.Order,
|
||||||
|
|
@ -697,12 +697,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReplaceAttributeRouteTokens(
|
private static void ReplaceAttributeRouteTokens(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IList<string> routeTemplateErrors)
|
IList<string> routeTemplateErrors)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
actionDescriptor.AttributeRouteInfo.Template = ReflectedAttributeRouteModel.ReplaceTokens(
|
actionDescriptor.AttributeRouteInfo.Template = AttributeRouteModel.ReplaceTokens(
|
||||||
actionDescriptor.AttributeRouteInfo.Template,
|
actionDescriptor.AttributeRouteInfo.Template,
|
||||||
actionDescriptor.RouteValueDefaults);
|
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)
|
foreach (var constraint in actionDescriptor.RouteConstraints)
|
||||||
{
|
{
|
||||||
|
|
@ -732,7 +732,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddRemovalConstraints(
|
private static void AddRemovalConstraints(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
ISet<string> removalConstraints)
|
ISet<string> removalConstraints)
|
||||||
{
|
{
|
||||||
foreach (var key in removalConstraints)
|
foreach (var key in removalConstraints)
|
||||||
|
|
@ -749,7 +749,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
private static void AddActionToNamedGroup(
|
private static void AddActionToNamedGroup(
|
||||||
IDictionary<string, IList<ActionDescriptor>> actionsByRouteName,
|
IDictionary<string, IList<ActionDescriptor>> actionsByRouteName,
|
||||||
string routeName,
|
string routeName,
|
||||||
ReflectedActionDescriptor actionDescriptor)
|
ControllerActionDescriptor actionDescriptor)
|
||||||
{
|
{
|
||||||
IList<ActionDescriptor> namedActionGroup;
|
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 &&
|
return actionDescriptor.AttributeRouteInfo != null &&
|
||||||
actionDescriptor.AttributeRouteInfo.Template != null;
|
actionDescriptor.AttributeRouteInfo.Template != null;
|
||||||
|
|
@ -829,8 +829,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateActionGroupConfiguration(
|
private void ValidateActionGroupConfiguration(
|
||||||
IDictionary<MethodInfo, IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>> methodMap,
|
IDictionary<MethodInfo, IDictionary<ActionModel, IList<ControllerActionDescriptor>>> methodMap,
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IDictionary<MethodInfo, string> routingConfigurationErrors)
|
IDictionary<MethodInfo, string> routingConfigurationErrors)
|
||||||
{
|
{
|
||||||
string combinedErrorMessage = null;
|
string combinedErrorMessage = null;
|
||||||
|
|
@ -838,7 +838,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var hasAttributeRoutedActions = false;
|
var hasAttributeRoutedActions = false;
|
||||||
var hasConventionallyRoutedActions = false;
|
var hasConventionallyRoutedActions = false;
|
||||||
|
|
||||||
var invalidHttpMethodActions = new Dictionary<ReflectedActionModel, IEnumerable<string>>();
|
var invalidHttpMethodActions = new Dictionary<ActionModel, IEnumerable<string>>();
|
||||||
|
|
||||||
var actionsForMethod = methodMap[actionDescriptor.MethodInfo];
|
var actionsForMethod = methodMap[actionDescriptor.MethodInfo];
|
||||||
foreach (var reflectedAction in actionsForMethod)
|
foreach (var reflectedAction in actionsForMethod)
|
||||||
|
|
@ -895,8 +895,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateActionHttpMethodProviders(
|
private static void ValidateActionHttpMethodProviders(
|
||||||
ReflectedActionModel reflectedAction,
|
ActionModel reflectedAction,
|
||||||
IDictionary<ReflectedActionModel, IEnumerable<string>> invalidHttpMethodActions)
|
IDictionary<ActionModel, IEnumerable<string>> invalidHttpMethodActions)
|
||||||
{
|
{
|
||||||
var invalidHttpMethodProviderAttributes = reflectedAction.Attributes
|
var invalidHttpMethodProviderAttributes = reflectedAction.Attributes
|
||||||
.Where(attr => attr is IActionHttpMethodProvider &&
|
.Where(attr => attr is IActionHttpMethodProvider &&
|
||||||
|
|
@ -929,9 +929,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CreateInvalidActionHttpMethodProviderErrorMessage(
|
private static string CreateInvalidActionHttpMethodProviderErrorMessage(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IDictionary<ReflectedActionModel, IEnumerable<string>> invalidHttpMethodActions,
|
IDictionary<ActionModel, IEnumerable<string>> invalidHttpMethodActions,
|
||||||
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod)
|
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod)
|
||||||
{
|
{
|
||||||
var messagesForMethodInfo = new List<string>();
|
var messagesForMethodInfo = new List<string>();
|
||||||
foreach (var invalidAction in invalidHttpMethodActions)
|
foreach (var invalidAction in invalidHttpMethodActions)
|
||||||
|
|
@ -981,8 +981,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CreateMixedRoutedActionDescriptorsErrorMessage(
|
private static string CreateMixedRoutedActionDescriptorsErrorMessage(
|
||||||
ReflectedActionDescriptor actionDescriptor,
|
ControllerActionDescriptor actionDescriptor,
|
||||||
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod)
|
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod)
|
||||||
{
|
{
|
||||||
// Text to show as the attribute route template for conventionally routed actions.
|
// Text to show as the attribute route template for conventionally routed actions.
|
||||||
var nullTemplate = Resources.AttributeRoute_NullTemplateRepresentation;
|
var nullTemplate = Resources.AttributeRoute_NullTemplateRepresentation;
|
||||||
|
|
@ -1044,12 +1044,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// public ActionResult List(){ ... }
|
// public ActionResult List(){ ... }
|
||||||
// }
|
// }
|
||||||
private class MethodToActionMap :
|
private class MethodToActionMap :
|
||||||
Dictionary<MethodInfo, IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>>
|
Dictionary<MethodInfo, IDictionary<ActionModel, IList<ControllerActionDescriptor>>>
|
||||||
{
|
{
|
||||||
public void AddToMethodInfo(ReflectedActionModel action,
|
public void AddToMethodInfo(ActionModel action,
|
||||||
IList<ReflectedActionDescriptor> actionDescriptors)
|
IList<ControllerActionDescriptor> actionDescriptors)
|
||||||
{
|
{
|
||||||
IDictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>> actionsForMethod = null;
|
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod = null;
|
||||||
if (TryGetValue(action.ActionMethod, out actionsForMethod))
|
if (TryGetValue(action.ActionMethod, out actionsForMethod))
|
||||||
{
|
{
|
||||||
actionsForMethod.Add(action, actionDescriptors);
|
actionsForMethod.Add(action, actionDescriptors);
|
||||||
|
|
@ -1057,7 +1057,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var reflectedActionMap =
|
var reflectedActionMap =
|
||||||
new Dictionary<ReflectedActionModel, IList<ReflectedActionDescriptor>>();
|
new Dictionary<ActionModel, IList<ControllerActionDescriptor>>();
|
||||||
reflectedActionMap.Add(action, actionDescriptors);
|
reflectedActionMap.Add(action, actionDescriptors);
|
||||||
Add(action.ActionMethod, reflectedActionMap);
|
Add(action.ActionMethod, reflectedActionMap);
|
||||||
}
|
}
|
||||||
|
|
@ -11,10 +11,10 @@ using Microsoft.AspNet.Mvc.Core;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public static class ReflectedActionExecutor
|
public static class ControllerActionExecutor
|
||||||
{
|
{
|
||||||
private static readonly MethodInfo _convertOfTMethod =
|
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.
|
// Method called via reflection.
|
||||||
private static Task<object> Convert<T>(object taskAsObject)
|
private static Task<object> Convert<T>(object taskAsObject)
|
||||||
|
|
@ -10,17 +10,17 @@ using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
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 IControllerFactory _controllerFactory;
|
||||||
private readonly IInputFormattersProvider _inputFormattersProvider;
|
private readonly IInputFormattersProvider _inputFormattersProvider;
|
||||||
|
|
||||||
public ReflectedActionInvoker([NotNull] ActionContext actionContext,
|
public ControllerActionInvoker([NotNull] ActionContext actionContext,
|
||||||
[NotNull] IActionBindingContextProvider bindingContextProvider,
|
[NotNull] IActionBindingContextProvider bindingContextProvider,
|
||||||
[NotNull] INestedProviderManager<FilterProviderContext> filterProvider,
|
[NotNull] INestedProviderManager<FilterProviderContext> filterProvider,
|
||||||
[NotNull] IControllerFactory controllerFactory,
|
[NotNull] IControllerFactory controllerFactory,
|
||||||
[NotNull] ReflectedActionDescriptor descriptor,
|
[NotNull] ControllerActionDescriptor descriptor,
|
||||||
[NotNull] IInputFormattersProvider inputFormattersProvider,
|
[NotNull] IInputFormattersProvider inputFormattersProvider,
|
||||||
[NotNull] IBodyModelValidator modelValidator)
|
[NotNull] IBodyModelValidator modelValidator)
|
||||||
: base(actionContext, bindingContextProvider, filterProvider, modelValidator)
|
: base(actionContext, bindingContextProvider, filterProvider, modelValidator)
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
Resources.FormatPropertyOfTypeCannotBeNull("MethodInfo",
|
Resources.FormatPropertyOfTypeCannotBeNull("MethodInfo",
|
||||||
typeof(ReflectedActionDescriptor)),
|
typeof(ControllerActionDescriptor)),
|
||||||
"descriptor");
|
"descriptor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
protected override async Task<IActionResult> InvokeActionAsync(ActionExecutingContext actionExecutingContext)
|
protected override async Task<IActionResult> InvokeActionAsync(ActionExecutingContext actionExecutingContext)
|
||||||
{
|
{
|
||||||
var actionMethodInfo = _descriptor.MethodInfo;
|
var actionMethodInfo = _descriptor.MethodInfo;
|
||||||
var actionReturnValue = await ReflectedActionExecutor.ExecuteAsync(
|
var actionReturnValue = await ControllerActionExecutor.ExecuteAsync(
|
||||||
actionMethodInfo,
|
actionMethodInfo,
|
||||||
ActionContext.Controller,
|
ActionContext.Controller,
|
||||||
actionExecutingContext.ActionArguments);
|
actionExecutingContext.ActionArguments);
|
||||||
|
|
@ -7,7 +7,7 @@ using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class ReflectedActionInvokerProvider : IActionInvokerProvider
|
public class ControllerActionInvokerProvider : IActionInvokerProvider
|
||||||
{
|
{
|
||||||
private readonly IControllerFactory _controllerFactory;
|
private readonly IControllerFactory _controllerFactory;
|
||||||
private readonly IActionBindingContextProvider _bindingProvider;
|
private readonly IActionBindingContextProvider _bindingProvider;
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
private readonly INestedProviderManager<FilterProviderContext> _filterProvider;
|
private readonly INestedProviderManager<FilterProviderContext> _filterProvider;
|
||||||
private readonly IBodyModelValidator _modelValidator;
|
private readonly IBodyModelValidator _modelValidator;
|
||||||
|
|
||||||
public ReflectedActionInvokerProvider(IControllerFactory controllerFactory,
|
public ControllerActionInvokerProvider(IControllerFactory controllerFactory,
|
||||||
IActionBindingContextProvider bindingProvider,
|
IActionBindingContextProvider bindingProvider,
|
||||||
IInputFormattersProvider inputFormattersProvider,
|
IInputFormattersProvider inputFormattersProvider,
|
||||||
INestedProviderManager<FilterProviderContext> filterProvider,
|
INestedProviderManager<FilterProviderContext> filterProvider,
|
||||||
|
|
@ -35,11 +35,11 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public void Invoke(ActionInvokerProviderContext context, Action callNext)
|
public void Invoke(ActionInvokerProviderContext context, Action callNext)
|
||||||
{
|
{
|
||||||
var actionDescriptor = context.ActionContext.ActionDescriptor as ReflectedActionDescriptor;
|
var actionDescriptor = context.ActionContext.ActionDescriptor as ControllerActionDescriptor;
|
||||||
|
|
||||||
if (actionDescriptor != null)
|
if (actionDescriptor != null)
|
||||||
{
|
{
|
||||||
context.Result = new ReflectedActionInvoker(
|
context.Result = new ControllerActionInvoker(
|
||||||
context.ActionContext,
|
context.ActionContext,
|
||||||
_bindingProvider,
|
_bindingProvider,
|
||||||
_filterProvider,
|
_filterProvider,
|
||||||
|
|
@ -24,12 +24,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public object CreateController(ActionContext actionContext)
|
public object CreateController(ActionContext actionContext)
|
||||||
{
|
{
|
||||||
var actionDescriptor = actionContext.ActionDescriptor as ReflectedActionDescriptor;
|
var actionDescriptor = actionContext.ActionDescriptor as ControllerActionDescriptor;
|
||||||
if (actionDescriptor == null)
|
if (actionDescriptor == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
Resources.FormatDefaultControllerFactory_ActionDescriptorMustBeReflected(
|
Resources.FormatDefaultControllerFactory_ActionDescriptorMustBeReflected(
|
||||||
typeof(ReflectedActionDescriptor)),
|
typeof(ControllerActionDescriptor)),
|
||||||
"actionContext");
|
"actionContext");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements a provider of <see cref="ApiDescription"/> for actions represented
|
/// Implements a provider of <see cref="ApiDescription"/> for actions represented
|
||||||
/// by <see cref="ReflectedActionDescriptor"/>.
|
/// by <see cref="ControllerActionDescriptor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DefaultApiDescriptionProvider : INestedProvider<ApiDescriptionProviderContext>
|
public class DefaultApiDescriptionProvider : INestedProvider<ApiDescriptionProviderContext>
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Invoke(ApiDescriptionProviderContext context, Action callNext)
|
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>();
|
var extensionData = action.GetProperty<ApiDescriptionActionData>();
|
||||||
if (extensionData != null)
|
if (extensionData != null)
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiDescription CreateApiDescription(
|
private ApiDescription CreateApiDescription(
|
||||||
ReflectedActionDescriptor action,
|
ControllerActionDescriptor action,
|
||||||
string httpMethod,
|
string httpMethod,
|
||||||
string groupName)
|
string groupName)
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
return apiDescription;
|
return apiDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetHttpMethods(ReflectedActionDescriptor action)
|
private IEnumerable<string> GetHttpMethods(ControllerActionDescriptor action)
|
||||||
{
|
{
|
||||||
if (action.ActionConstraints != null && action.ActionConstraints.Count > 0)
|
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
|
// This is a placeholder for functionality which will correctly generate the relative path
|
||||||
// stub of an action. See: #885
|
// stub of an action. See: #885
|
||||||
|
|
@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
}
|
}
|
||||||
|
|
||||||
private IReadOnlyList<ApiResponseFormat> GetResponseFormats(
|
private IReadOnlyList<ApiResponseFormat> GetResponseFormats(
|
||||||
ReflectedActionDescriptor action,
|
ControllerActionDescriptor action,
|
||||||
IApiResponseMetadataProvider[] responseMetadataAttributes,
|
IApiResponseMetadataProvider[] responseMetadataAttributes,
|
||||||
Type declaredType,
|
Type declaredType,
|
||||||
Type runtimeType)
|
Type runtimeType)
|
||||||
|
|
@ -221,7 +221,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Type GetDeclaredReturnType(ReflectedActionDescriptor action)
|
private Type GetDeclaredReturnType(ControllerActionDescriptor action)
|
||||||
{
|
{
|
||||||
var declaredReturnType = action.MethodInfo.ReturnType;
|
var declaredReturnType = action.MethodInfo.ReturnType;
|
||||||
if (declaredReturnType == typeof(void) ||
|
if (declaredReturnType == typeof(void) ||
|
||||||
|
|
@ -281,7 +281,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
return declaredReturnType;
|
return declaredReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IApiResponseMetadataProvider[] GetResponseMetadataAttributes(ReflectedActionDescriptor action)
|
private IApiResponseMetadataProvider[] GetResponseMetadataAttributes(ControllerActionDescriptor action)
|
||||||
{
|
{
|
||||||
if (action.FilterDescriptors == null)
|
if (action.FilterDescriptors == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Mvc.Core;
|
using Microsoft.AspNet.Mvc.Core;
|
||||||
using Microsoft.AspNet.Mvc.OptionDescriptors;
|
using Microsoft.AspNet.Mvc.OptionDescriptors;
|
||||||
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
|
using Microsoft.AspNet.Mvc.ApplicationModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
public MvcOptions()
|
public MvcOptions()
|
||||||
{
|
{
|
||||||
ApplicationModelConventions = new List<IReflectedApplicationModelConvention>();
|
ApplicationModelConventions = new List<IGlobalModelConvention>();
|
||||||
ModelBinders = new List<ModelBinderDescriptor>();
|
ModelBinders = new List<ModelBinderDescriptor>();
|
||||||
ViewEngines = new List<ViewEngineDescriptor>();
|
ViewEngines = new List<ViewEngineDescriptor>();
|
||||||
ValueProviderFactories = new List<ValueProviderFactoryDescriptor>();
|
ValueProviderFactories = new List<ValueProviderFactoryDescriptor>();
|
||||||
|
|
@ -113,6 +113,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
|
public List<ValueProviderFactoryDescriptor> ValueProviderFactories { get; private set; }
|
||||||
|
|
||||||
public List<IReflectedApplicationModelConvention> ApplicationModelConventions { get; private set; }
|
public List<IGlobalModelConvention> ApplicationModelConventions { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
var component = CreateComponent(context);
|
var component = CreateComponent(context);
|
||||||
|
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(method, component, _args);
|
var result = await ControllerActionExecutor.ExecuteAsync(method, component, _args);
|
||||||
|
|
||||||
return CoerceToViewComponentResult(result);
|
return CoerceToViewComponentResult(result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
yield return describe.Singleton<IFileInfoCache, ExpiringFileInfoCache>();
|
yield return describe.Singleton<IFileInfoCache, ExpiringFileInfoCache>();
|
||||||
|
|
||||||
yield return describe.Transient<INestedProvider<ActionDescriptorProviderContext>,
|
yield return describe.Transient<INestedProvider<ActionDescriptorProviderContext>,
|
||||||
ReflectedActionDescriptorProvider>();
|
ControllerActionDescriptorProvider>();
|
||||||
yield return describe.Transient<INestedProvider<ActionInvokerProviderContext>,
|
yield return describe.Transient<INestedProvider<ActionInvokerProviderContext>,
|
||||||
ReflectedActionInvokerProvider>();
|
ControllerActionInvokerProvider>();
|
||||||
yield return describe.Singleton<IActionDescriptorsCollectionProvider,
|
yield return describe.Singleton<IActionDescriptorsCollectionProvider,
|
||||||
DefaultActionDescriptorsCollectionProvider>();
|
DefaultActionDescriptorsCollectionProvider>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = actionDescriptorProvider.GetDescriptors()
|
var result = actionDescriptorProvider.GetDescriptors()
|
||||||
.Select(x => x as ReflectedActionDescriptor)
|
.Select(x => x as ControllerActionDescriptor)
|
||||||
.FirstOrDefault(
|
.FirstOrDefault(
|
||||||
x=> x.ControllerName == "NonAction" &&
|
x=> x.ControllerName == "NonAction" &&
|
||||||
x.Name == actionName);
|
x.Name == actionName);
|
||||||
|
|
@ -193,7 +193,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return await defaultActionSelector.SelectAsync(context);
|
return await defaultActionSelector.SelectAsync(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionDescriptorProvider GetActionDescriptorProvider(
|
private ControllerActionDescriptorProvider GetActionDescriptorProvider(
|
||||||
IActionDiscoveryConventions actionDiscoveryConventions = null)
|
IActionDiscoveryConventions actionDiscoveryConventions = null)
|
||||||
{
|
{
|
||||||
var controllerAssemblyProvider = new StaticControllerAssemblyProvider();
|
var controllerAssemblyProvider = new StaticControllerAssemblyProvider();
|
||||||
|
|
@ -207,7 +207,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
|
actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReflectedActionDescriptorProvider(
|
return new ControllerActionDescriptorProvider(
|
||||||
controllerAssemblyProvider,
|
controllerAssemblyProvider,
|
||||||
actionDiscoveryConventions,
|
actionDiscoveryConventions,
|
||||||
new TestGlobalFilterProvider(),
|
new TestGlobalFilterProvider(),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
public async Task AsyncAction_WithVoidReturnType()
|
public async Task AsyncAction_WithVoidReturnType()
|
||||||
{
|
{
|
||||||
var methodWithVoidReturnType = new MethodWithVoidReturnType(TestController.VoidAction);
|
var methodWithVoidReturnType = new MethodWithVoidReturnType(TestController.VoidAction);
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(
|
var result = await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithVoidReturnType.GetMethodInfo(),
|
methodWithVoidReturnType.GetMethodInfo(),
|
||||||
null,
|
null,
|
||||||
(IDictionary<string, object>)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 actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
|
||||||
|
|
||||||
var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction);
|
var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction);
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(
|
var result = await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskReturnType.GetMethodInfo(),
|
methodWithTaskReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters);
|
actionParameters);
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
|
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
|
||||||
|
|
||||||
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
|
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(
|
var result = await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters);
|
actionParameters);
|
||||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
|
var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } };
|
||||||
|
|
||||||
var methodWithTaskOfTaskOfIntReturnType = new MethodWithTaskOfTaskOfIntReturnType(_controller.TaskOfTaskAction);
|
var methodWithTaskOfTaskOfIntReturnType = new MethodWithTaskOfTaskOfIntReturnType(_controller.TaskOfTaskAction);
|
||||||
var result = await (Task<int>)(await ReflectedActionExecutor.ExecuteAsync(
|
var result = await (Task<int>)(await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskOfTaskOfIntReturnType.GetMethodInfo(),
|
methodWithTaskOfTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters));
|
actionParameters));
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
await Assert.ThrowsAsync<NotImplementedException>(
|
await Assert.ThrowsAsync<NotImplementedException>(
|
||||||
() => ReflectedActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
|
() => ControllerActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters));
|
actionParameters));
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
|
|
||||||
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionWithExceptionWithoutAsync);
|
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionWithExceptionWithoutAsync);
|
||||||
await Assert.ThrowsAsync<NotImplementedException>(
|
await Assert.ThrowsAsync<NotImplementedException>(
|
||||||
() => ReflectedActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
|
() => ControllerActionExecutor.ExecuteAsync(methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters));
|
actionParameters));
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionThrowAfterAwait);
|
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskActionThrowAfterAwait);
|
||||||
await AssertThrowsAsync<ArgumentException>(
|
await AssertThrowsAsync<ArgumentException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
{
|
{
|
||||||
string inputString = "hello";
|
string inputString = "hello";
|
||||||
var syncMethod = new SyncMethod(_controller.Echo);
|
var syncMethod = new SyncMethod(_controller.Echo);
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(
|
var result = await ControllerActionExecutor.ExecuteAsync(
|
||||||
syncMethod.GetMethodInfo(),
|
syncMethod.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
new Dictionary<string, object>() { { "input", inputString } });
|
new Dictionary<string, object>() { { "input", inputString } });
|
||||||
|
|
@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
string inputString = "hello";
|
string inputString = "hello";
|
||||||
var syncMethod = new SyncMethod(_controller.EchoWithException);
|
var syncMethod = new SyncMethod(_controller.EchoWithException);
|
||||||
await Assert.ThrowsAsync<NotImplementedException>(
|
await Assert.ThrowsAsync<NotImplementedException>(
|
||||||
() => ReflectedActionExecutor.ExecuteAsync(
|
() => ControllerActionExecutor.ExecuteAsync(
|
||||||
syncMethod.GetMethodInfo(),
|
syncMethod.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
new Dictionary<string, object>() { { "input", inputString } }));
|
new Dictionary<string, object>() { { "input", inputString } }));
|
||||||
|
|
@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
typeof(TestController));
|
typeof(TestController));
|
||||||
await AssertThrowsAsync<InvalidOperationException>(
|
await AssertThrowsAsync<InvalidOperationException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithCutomTaskReturnType.GetMethodInfo(),
|
methodWithCutomTaskReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
@ -196,7 +196,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
|
|
||||||
await AssertThrowsAsync<InvalidOperationException>(
|
await AssertThrowsAsync<InvalidOperationException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithCutomTaskOfTReturnType.GetMethodInfo(),
|
methodWithCutomTaskOfTReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
@ -213,7 +213,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask);
|
var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask);
|
||||||
await AssertThrowsAsync<InvalidOperationException>(
|
await AssertThrowsAsync<InvalidOperationException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithUnwrappedTask.GetMethodInfo(),
|
methodWithUnwrappedTask.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
@ -238,7 +238,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
typeof(TestController));
|
typeof(TestController));
|
||||||
await AssertThrowsAsync<InvalidOperationException>(
|
await AssertThrowsAsync<InvalidOperationException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
dynamicTaskMethod.GetMethodInfo(),
|
dynamicTaskMethod.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var actionParameters = new Dictionary<string, object> { { "s", inputParam2 }, { "i", inputParam1 } };
|
var actionParameters = new Dictionary<string, object> { { "s", inputParam2 }, { "i", inputParam1 } };
|
||||||
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
|
var methodWithTaskOfIntReturnType = new MethodWithTaskOfIntReturnType(_controller.TaskValueTypeAction);
|
||||||
|
|
||||||
var result = await ReflectedActionExecutor.ExecuteAsync(
|
var result = await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters);
|
actionParameters);
|
||||||
|
|
@ -280,7 +280,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
// If it is an unrecognized derived type we throw an InvalidOperationException.
|
// If it is an unrecognized derived type we throw an InvalidOperationException.
|
||||||
await AssertThrowsAsync<ArgumentException>(
|
await AssertThrowsAsync<ArgumentException>(
|
||||||
async () =>
|
async () =>
|
||||||
await ReflectedActionExecutor.ExecuteAsync(
|
await ControllerActionExecutor.ExecuteAsync(
|
||||||
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
methodWithTaskOfIntReturnType.GetMethodInfo(),
|
||||||
_controller,
|
_controller,
|
||||||
actionParameters),
|
actionParameters),
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
namespace Microsoft.AspNet.Mvc.ApplicationModel
|
||||||
{
|
{
|
||||||
public class ReflectedAttributeRouteModelTests
|
public class AttributeRouteModelTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(null, null, null)]
|
[InlineData(null, null, null)]
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
public void Combine_EmptyTemplates(string left, string right, string expected)
|
public void Combine_EmptyTemplates(string left, string right, string expected)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
|
var combined = AttributeRouteModel.CombineTemplates(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, combined);
|
Assert.Equal(expected, combined);
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
public void Combine_OneTemplateHasValue(string left, string right, string expected)
|
public void Combine_OneTemplateHasValue(string left, string right, string expected)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
|
var combined = AttributeRouteModel.CombineTemplates(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, combined);
|
Assert.Equal(expected, combined);
|
||||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
public void Combine_BothTemplatesHasValue(string left, string right, string expected)
|
public void Combine_BothTemplatesHasValue(string left, string right, string expected)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
|
var combined = AttributeRouteModel.CombineTemplates(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, combined);
|
Assert.Equal(expected, combined);
|
||||||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
public void Combine_InvalidTemplates(string left, string right, string expected)
|
public void Combine_InvalidTemplates(string left, string right, string expected)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineTemplates(left, right);
|
var combined = AttributeRouteModel.CombineTemplates(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, combined);
|
Assert.Equal(expected, combined);
|
||||||
|
|
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = ReflectedAttributeRouteModel.ReplaceTokens(template, valuesDictionary);
|
var result = AttributeRouteModel.ReplaceTokens(template, valuesDictionary);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, result);
|
Assert.Equal(expected, result);
|
||||||
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => { ReflectedAttributeRouteModel.ReplaceTokens(template, valuesDictionary); });
|
() => { AttributeRouteModel.ReplaceTokens(template, valuesDictionary); });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, ex.Message);
|
Assert.Equal(expected, ex.Message);
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(
|
var ex = Assert.Throws<InvalidOperationException>(
|
||||||
() => { ReflectedAttributeRouteModel.ReplaceTokens(template, values); });
|
() => { AttributeRouteModel.ReplaceTokens(template, values); });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expected, ex.Message);
|
Assert.Equal(expected, ex.Message);
|
||||||
|
|
@ -171,12 +171,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(CombineOrdersTestData))]
|
[MemberData(nameof(CombineOrdersTestData))]
|
||||||
public void Combine_Orders(
|
public void Combine_Orders(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right,
|
AttributeRouteModel right,
|
||||||
int? expected)
|
int? expected)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
|
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(combined);
|
Assert.NotNull(combined);
|
||||||
|
|
@ -186,12 +186,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(ValidReflectedAttributeRouteModelsTestData))]
|
[MemberData(nameof(ValidReflectedAttributeRouteModelsTestData))]
|
||||||
public void Combine_ValidReflectedAttributeRouteModels(
|
public void Combine_ValidReflectedAttributeRouteModels(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right,
|
AttributeRouteModel right,
|
||||||
ReflectedAttributeRouteModel expectedResult)
|
AttributeRouteModel expectedResult)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
|
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(combined);
|
Assert.NotNull(combined);
|
||||||
|
|
@ -201,11 +201,11 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(NullOrNullTemplateReflectedAttributeRouteModelTestData))]
|
[MemberData(nameof(NullOrNullTemplateReflectedAttributeRouteModelTestData))]
|
||||||
public void Combine_NullOrNullTemplateReflectedAttributeRouteModels(
|
public void Combine_NullOrNullTemplateReflectedAttributeRouteModels(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right)
|
AttributeRouteModel right)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
|
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Null(combined);
|
Assert.Null(combined);
|
||||||
|
|
@ -214,14 +214,14 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(RightOverridesReflectedAttributeRouteModelTestData))]
|
[MemberData(nameof(RightOverridesReflectedAttributeRouteModelTestData))]
|
||||||
public void Combine_RightOverridesReflectedAttributeRouteModel(
|
public void Combine_RightOverridesReflectedAttributeRouteModel(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right)
|
AttributeRouteModel right)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedTemplate = ReflectedAttributeRouteModel.CombineTemplates(null, right.Template);
|
var expectedTemplate = AttributeRouteModel.CombineTemplates(null, right.Template);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
|
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(combined);
|
Assert.NotNull(combined);
|
||||||
|
|
@ -232,12 +232,12 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(CombineNamesTestData))]
|
[MemberData(nameof(CombineNamesTestData))]
|
||||||
public void Combine_Names(
|
public void Combine_Names(
|
||||||
ReflectedAttributeRouteModel left,
|
AttributeRouteModel left,
|
||||||
ReflectedAttributeRouteModel right,
|
AttributeRouteModel right,
|
||||||
string expectedName)
|
string expectedName)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var combined = ReflectedAttributeRouteModel.CombineReflectedAttributeRouteModel(left, right);
|
var combined = AttributeRouteModel.CombineAttributeRouteModel(left, right);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(combined);
|
Assert.NotNull(combined);
|
||||||
|
|
@ -249,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// AttributeRoute on the controller, attribute route on the action, expected name.
|
// 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.
|
// Combined name is null if no name is provided.
|
||||||
data.Add(Create(template: "/", order: null, name: null), null, null);
|
data.Add(Create(template: "/", order: null, name: null), null, null);
|
||||||
|
|
@ -302,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// AttributeRoute on the controller, attribute route on the action, expected order.
|
// 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: 2), 2);
|
||||||
data.Add(Create("", order: 1), Create("", order: null), 1);
|
data.Add(Create("", order: 1), Create("", order: null), 1);
|
||||||
|
|
@ -331,7 +331,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// AttributeRoute on the controller, attribute route on the action.
|
// 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);
|
var leftModel = Create("Home", order: 3);
|
||||||
|
|
||||||
data.Add(leftModel, Create("/"));
|
data.Add(leftModel, Create("/"));
|
||||||
|
|
@ -350,7 +350,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// AttributeRoute on the controller, attribute route on the action.
|
// 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, null);
|
||||||
data.Add(null, Create(null));
|
data.Add(null, Create(null));
|
||||||
|
|
@ -366,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.ReflectedModelBuilder
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// AttributeRoute on the controller, attribute route on the action, expected combined attribute route.
|
// 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(null, Create("Index"), Create("Index"));
|
||||||
data.Add(Create(null), Create("Index"), Create("Index"));
|
data.Add(Create(null), Create("Index"), Create("Index"));
|
||||||
data.Add(Create("Home"), null, Create("Home"));
|
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,
|
Template = template,
|
||||||
Order = order,
|
Order = order,
|
||||||
|
|
@ -7,14 +7,14 @@ using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.Description;
|
using Microsoft.AspNet.Mvc.Description;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
using Microsoft.AspNet.Mvc.Routing;
|
||||||
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
|
using Microsoft.AspNet.Mvc.ApplicationModel;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Test
|
namespace Microsoft.AspNet.Mvc.Test
|
||||||
{
|
{
|
||||||
public class ReflectedActionDescriptorProviderTests
|
public class ControllerActionDescriptorProviderTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetDescriptors_GetsDescriptorsOnlyForValidActions()
|
public void GetDescriptors_GetsDescriptorsOnlyForValidActions()
|
||||||
|
|
@ -85,18 +85,18 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
"The following errors occurred with attribute routing information:" + Environment.NewLine +
|
"The following errors occurred with attribute routing information:" + Environment.NewLine +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
"Error 1:" + Environment.NewLine +
|
"Error 1:" + Environment.NewLine +
|
||||||
"A method 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"A method 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"AttributeRoutedHttpMethodController.PutOrPatch'" +
|
"AttributeRoutedHttpMethodController.PutOrPatch'" +
|
||||||
" that defines attribute routed actions must not have attributes that implement " +
|
" that defines attribute routed actions must not have attributes that implement " +
|
||||||
"'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement " +
|
"'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement " +
|
||||||
"'Microsoft.AspNet.Mvc.Routing.IRouteTemplateProvider':" + Environment.NewLine +
|
"'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 " +
|
"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 +
|
" 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 " +
|
"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.";
|
" invalid 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' attributes.";
|
||||||
|
|
||||||
var provider = GetProvider(
|
var provider = GetProvider(
|
||||||
|
|
@ -466,7 +466,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BuildModel_CreatesReflectedControllerModels_ForAllControllers()
|
public void BuildModel_CreatesControllerModels_ForAllControllers()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var provider = GetProvider(
|
var provider = GetProvider(
|
||||||
|
|
@ -502,7 +502,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BuildModel_CreatesReflectedActionDescriptors_ForValidActions()
|
public void BuildModel_CreatesControllerActionDescriptors_ForValidActions()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var provider = GetProvider(
|
var provider = GetProvider(
|
||||||
|
|
@ -539,8 +539,8 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
"Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+PersonController.GetPerson",
|
"Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+PersonController.GetPerson",
|
||||||
"Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+PersonController.ListPeople",
|
"Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+PersonController.ListPeople",
|
||||||
},
|
},
|
||||||
displayNames);
|
displayNames);
|
||||||
}
|
}
|
||||||
|
|
@ -587,13 +587,13 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
"The following errors occurred with attribute routing information:" + Environment.NewLine +
|
"The following errors occurred with attribute routing information:" + Environment.NewLine +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
"Error 1:" + Environment.NewLine +
|
"Error 1:" + Environment.NewLine +
|
||||||
"For action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"For action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"MultipleErrorsController.Unknown'" + Environment.NewLine +
|
"MultipleErrorsController.Unknown'" + Environment.NewLine +
|
||||||
"Error: While processing template 'stub/[action]/[unknown]', a replacement value for the token 'unknown' " +
|
"Error: While processing template 'stub/[action]/[unknown]', a replacement value for the token 'unknown' " +
|
||||||
"could not be found. Available tokens: 'controller, action'." + Environment.NewLine +
|
"could not be found. Available tokens: 'controller, action'." + Environment.NewLine +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
"Error 2:" + Environment.NewLine +
|
"Error 2:" + Environment.NewLine +
|
||||||
"For action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"For action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"MultipleErrorsController.Invalid'" + Environment.NewLine +
|
"MultipleErrorsController.Invalid'" + Environment.NewLine +
|
||||||
"Error: The route template '[invalid/syntax' has invalid syntax. A replacement token is not closed.";
|
"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 +
|
"The following errors occurred with attribute routing information:" + Environment.NewLine +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
"Error 1:" + Environment.NewLine +
|
"Error 1:" + Environment.NewLine +
|
||||||
"A method 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"A method 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method'" +
|
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method'" +
|
||||||
" must not define attribute routed actions and non attribute routed actions at the same time:" + Environment.NewLine +
|
" 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 +
|
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: 'AttributeRouted'" + Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: '(none)'" + Environment.NewLine +
|
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: '(none)'" + Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' - Template: '(none)'" + Environment.NewLine +
|
"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" +
|
"AttributeAndNonAttributeRoutedActionsOnSameMethodController.Method' that defines attribute routed actions must not" +
|
||||||
" have attributes that implement 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement" +
|
" have attributes that implement 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' and do not implement" +
|
||||||
" 'Microsoft.AspNet.Mvc.Routing.IRouteTemplateProvider':" + Environment.NewLine +
|
" '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 " +
|
"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.";
|
" invalid 'Microsoft.AspNet.Mvc.IActionHttpMethodProvider' attributes.";
|
||||||
|
|
||||||
var provider = GetProvider(
|
var provider = GetProvider(
|
||||||
|
|
@ -847,37 +847,37 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
"Error 1:" + Environment.NewLine +
|
"Error 1:" + Environment.NewLine +
|
||||||
"Attribute routes with the same name 'Products' must have the same template:"
|
"Attribute routes with the same name 'Products' must have the same template:"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.Get' - Template: 'Products'"
|
"SameNameDifferentTemplatesController.Get' - Template: 'Products'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.Get' - Template: 'Products/{id}'"
|
"SameNameDifferentTemplatesController.Get' - Template: 'Products/{id}'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.Put' - Template: 'Products/{id}'"
|
"SameNameDifferentTemplatesController.Put' - Template: 'Products/{id}'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.Post' - Template: 'Products'"
|
"SameNameDifferentTemplatesController.Post' - Template: 'Products'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.Delete' - Template: 'Products/{id}'"
|
"SameNameDifferentTemplatesController.Delete' - Template: 'Products/{id}'"
|
||||||
+ Environment.NewLine + Environment.NewLine +
|
+ Environment.NewLine + Environment.NewLine +
|
||||||
"Error 2:" + Environment.NewLine +
|
"Error 2:" + Environment.NewLine +
|
||||||
"Attribute routes with the same name 'Items' must have the same template:"
|
"Attribute routes with the same name 'Items' must have the same template:"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.GetItems' - Template: 'Items/{id}'"
|
"SameNameDifferentTemplatesController.GetItems' - Template: 'Items/{id}'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.PostItems' - Template: 'Items'"
|
"SameNameDifferentTemplatesController.PostItems' - Template: 'Items'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.PutItems' - Template: 'Items/{id}'"
|
"SameNameDifferentTemplatesController.PutItems' - Template: 'Items/{id}'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.DeleteItems' - Template: 'Items/{id}'"
|
"SameNameDifferentTemplatesController.DeleteItems' - Template: 'Items/{id}'"
|
||||||
+ Environment.NewLine +
|
+ Environment.NewLine +
|
||||||
"Action: 'Microsoft.AspNet.Mvc.Test.ReflectedActionDescriptorProviderTests+" +
|
"Action: 'Microsoft.AspNet.Mvc.Test.ControllerActionDescriptorProviderTests+" +
|
||||||
"SameNameDifferentTemplatesController.PatchItems' - Template: 'Items'";
|
"SameNameDifferentTemplatesController.PatchItems' - Template: 'Items'";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -1142,24 +1142,24 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
// Arrange
|
// Arrange
|
||||||
var sequence = 0;
|
var sequence = 0;
|
||||||
|
|
||||||
var applicationConvention = new Mock<IReflectedApplicationModelConvention>();
|
var applicationConvention = new Mock<IGlobalModelConvention>();
|
||||||
applicationConvention
|
applicationConvention
|
||||||
.Setup(c => c.Apply(It.IsAny<ReflectedApplicationModel>()))
|
.Setup(c => c.Apply(It.IsAny<GlobalModel>()))
|
||||||
.Callback(() => { Assert.Equal(0, sequence++); });
|
.Callback(() => { Assert.Equal(0, sequence++); });
|
||||||
|
|
||||||
var controllerConvention = new Mock<IReflectedControllerModelConvention>();
|
var controllerConvention = new Mock<IControllerModelConvention>();
|
||||||
controllerConvention
|
controllerConvention
|
||||||
.Setup(c => c.Apply(It.IsAny<ReflectedControllerModel>()))
|
.Setup(c => c.Apply(It.IsAny<ControllerModel>()))
|
||||||
.Callback(() => { Assert.Equal(1, sequence++); });
|
.Callback(() => { Assert.Equal(1, sequence++); });
|
||||||
|
|
||||||
var actionConvention = new Mock<IReflectedActionModelConvention>();
|
var actionConvention = new Mock<IActionModelConvention>();
|
||||||
actionConvention
|
actionConvention
|
||||||
.Setup(c => c.Apply(It.IsAny<ReflectedActionModel>()))
|
.Setup(c => c.Apply(It.IsAny<ActionModel>()))
|
||||||
.Callback(() => { Assert.Equal(2, sequence++); });
|
.Callback(() => { Assert.Equal(2, sequence++); });
|
||||||
|
|
||||||
var parameterConvention = new Mock<IReflectedParameterModelConvention>();
|
var parameterConvention = new Mock<IParameterModelConvention>();
|
||||||
parameterConvention
|
parameterConvention
|
||||||
.Setup(c => c.Apply(It.IsAny<ReflectedParameterModel>()))
|
.Setup(c => c.Apply(It.IsAny<ParameterModel>()))
|
||||||
.Callback(() => { Assert.Equal(3, sequence++); });
|
.Callback(() => { Assert.Equal(3, sequence++); });
|
||||||
|
|
||||||
var options = new MockMvcOptionsAccessor();
|
var options = new MockMvcOptionsAccessor();
|
||||||
|
|
@ -1328,7 +1328,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
Assert.Single(action.ActionConstraints, a => a is ConstraintAttribute);
|
Assert.Single(action.ActionConstraints, a => a is ConstraintAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionDescriptorProvider GetProvider(
|
private ControllerActionDescriptorProvider GetProvider(
|
||||||
TypeInfo controllerTypeInfo,
|
TypeInfo controllerTypeInfo,
|
||||||
IEnumerable<IFilter> filters = null)
|
IEnumerable<IFilter> filters = null)
|
||||||
{
|
{
|
||||||
|
|
@ -1339,7 +1339,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
.SetupGet(ap => ap.CandidateAssemblies)
|
.SetupGet(ap => ap.CandidateAssemblies)
|
||||||
.Returns(new Assembly[] { controllerTypeInfo.Assembly });
|
.Returns(new Assembly[] { controllerTypeInfo.Assembly });
|
||||||
|
|
||||||
var provider = new ReflectedActionDescriptorProvider(
|
var provider = new ControllerActionDescriptorProvider(
|
||||||
assemblyProvider.Object,
|
assemblyProvider.Object,
|
||||||
conventions,
|
conventions,
|
||||||
new TestGlobalFilterProvider(filters),
|
new TestGlobalFilterProvider(filters),
|
||||||
|
|
@ -1348,7 +1348,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionDescriptorProvider GetProvider(
|
private ControllerActionDescriptorProvider GetProvider(
|
||||||
params TypeInfo[] controllerTypeInfo)
|
params TypeInfo[] controllerTypeInfo)
|
||||||
{
|
{
|
||||||
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo);
|
var conventions = new StaticActionDiscoveryConventions(controllerTypeInfo);
|
||||||
|
|
@ -1358,7 +1358,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
.SetupGet(ap => ap.CandidateAssemblies)
|
.SetupGet(ap => ap.CandidateAssemblies)
|
||||||
.Returns(new Assembly[] { controllerTypeInfo.First().Assembly });
|
.Returns(new Assembly[] { controllerTypeInfo.First().Assembly });
|
||||||
|
|
||||||
var provider = new ReflectedActionDescriptorProvider(
|
var provider = new ControllerActionDescriptorProvider(
|
||||||
assemblyProvider.Object,
|
assemblyProvider.Object,
|
||||||
conventions,
|
conventions,
|
||||||
new TestGlobalFilterProvider(),
|
new TestGlobalFilterProvider(),
|
||||||
|
|
@ -1367,7 +1367,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionDescriptorProvider GetProvider(
|
private ControllerActionDescriptorProvider GetProvider(
|
||||||
TypeInfo type,
|
TypeInfo type,
|
||||||
IOptionsAccessor<MvcOptions> options)
|
IOptionsAccessor<MvcOptions> options)
|
||||||
{
|
{
|
||||||
|
|
@ -1378,7 +1378,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
.SetupGet(ap => ap.CandidateAssemblies)
|
.SetupGet(ap => ap.CandidateAssemblies)
|
||||||
.Returns(new Assembly[] { type.Assembly });
|
.Returns(new Assembly[] { type.Assembly });
|
||||||
|
|
||||||
return new ReflectedActionDescriptorProvider(
|
return new ControllerActionDescriptorProvider(
|
||||||
assemblyProvider.Object,
|
assemblyProvider.Object,
|
||||||
conventions,
|
conventions,
|
||||||
new TestGlobalFilterProvider(),
|
new TestGlobalFilterProvider(),
|
||||||
|
|
@ -1394,7 +1394,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
.SetupGet(ap => ap.CandidateAssemblies)
|
.SetupGet(ap => ap.CandidateAssemblies)
|
||||||
.Returns(controllerTypeInfos.Select(cti => cti.Assembly).Distinct());
|
.Returns(controllerTypeInfos.Select(cti => cti.Assembly).Distinct());
|
||||||
|
|
||||||
var provider = new ReflectedActionDescriptorProvider(
|
var provider = new ControllerActionDescriptorProvider(
|
||||||
assemblyProvider.Object,
|
assemblyProvider.Object,
|
||||||
conventions,
|
conventions,
|
||||||
new TestGlobalFilterProvider(),
|
new TestGlobalFilterProvider(),
|
||||||
|
|
@ -18,7 +18,7 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class ReflectedActionInvokerTest
|
public class ControllerActionInvokerTest
|
||||||
{
|
{
|
||||||
// Intentionally choosing an uncommon exception type.
|
// Intentionally choosing an uncommon exception type.
|
||||||
private readonly Exception _actionException = new TimeZoneNotFoundException();
|
private readonly Exception _actionException = new TimeZoneNotFoundException();
|
||||||
|
|
@ -1212,7 +1212,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var mockActionResult = new Mock<IActionResult>();
|
var mockActionResult = new Mock<IActionResult>();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var result = ReflectedActionInvoker.CreateActionResult(
|
var result = ControllerActionInvoker.CreateActionResult(
|
||||||
mockActionResult.Object.GetType(), mockActionResult.Object);
|
mockActionResult.Object.GetType(), mockActionResult.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -1225,7 +1225,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange, Act & Assert
|
// Arrange, Act & Assert
|
||||||
ExceptionAssert.Throws<InvalidOperationException>(
|
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 '"
|
"Cannot return null from an action method with a return type of '"
|
||||||
+ typeof(IActionResult)
|
+ typeof(IActionResult)
|
||||||
+ "'.");
|
+ "'.");
|
||||||
|
|
@ -1237,7 +1237,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public void CreateActionResult_Types_ReturnsObjectResultForTaskAndVoidReturnTypes(Type type)
|
public void CreateActionResult_Types_ReturnsObjectResultForTaskAndVoidReturnTypes(Type type)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var result = ReflectedActionInvoker.CreateActionResult(type, null);
|
var result = ControllerActionInvoker.CreateActionResult(type, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var objectResult = Assert.IsType<ObjectResult>(result);
|
var objectResult = Assert.IsType<ObjectResult>(result);
|
||||||
|
|
@ -1269,21 +1269,21 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public void CreateActionResult_ReturnsObjectContentResult(Type type, object input)
|
public void CreateActionResult_ReturnsObjectContentResult(Type type, object input)
|
||||||
{
|
{
|
||||||
// Arrange & Act
|
// Arrange & Act
|
||||||
var actualResult = ReflectedActionInvoker.CreateActionResult(type, input);
|
var actualResult = ControllerActionInvoker.CreateActionResult(type, input);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var contentResult = Assert.IsType<ObjectResult>(actualResult);
|
var contentResult = Assert.IsType<ObjectResult>(actualResult);
|
||||||
Assert.Same(input, contentResult.Value);
|
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);
|
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>(),
|
FilterDescriptors = new List<FilterDescriptor>(),
|
||||||
Parameters = new List<ParameterDescriptor>(),
|
Parameters = new List<ParameterDescriptor>(),
|
||||||
|
|
@ -1291,11 +1291,11 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
if (actionThrows)
|
if (actionThrows)
|
||||||
{
|
{
|
||||||
actionDescriptor.MethodInfo = typeof(ReflectedActionInvokerTest).GetMethod("ThrowingActionMethod");
|
actionDescriptor.MethodInfo = typeof(ControllerActionInvokerTest).GetMethod("ThrowingActionMethod");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actionDescriptor.MethodInfo = typeof(ReflectedActionInvokerTest).GetMethod("ActionMethod");
|
actionDescriptor.MethodInfo = typeof(ControllerActionInvokerTest).GetMethod("ActionMethod");
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpContext = new Mock<HttpContext>(MockBehavior.Loose);
|
var httpContext = new Mock<HttpContext>(MockBehavior.Loose);
|
||||||
|
|
@ -1339,7 +1339,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
|
|
||||||
var invoker = new TestReflectedActionInvoker(
|
var invoker = new TestControllerActionInvoker(
|
||||||
actionContext,
|
actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
filterProvider.Object,
|
filterProvider.Object,
|
||||||
|
|
@ -1356,7 +1356,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Func<object, int> method = x => 1;
|
Func<object, int> method = x => 1;
|
||||||
var actionDescriptor = new ReflectedActionDescriptor
|
var actionDescriptor = new ControllerActionDescriptor
|
||||||
{
|
{
|
||||||
MethodInfo = method.Method,
|
MethodInfo = method.Method,
|
||||||
Parameters = new List<ParameterDescriptor>
|
Parameters = new List<ParameterDescriptor>
|
||||||
|
|
@ -1386,7 +1386,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
var invoker = new ReflectedActionInvoker(actionContext,
|
var invoker = new ControllerActionInvoker(actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
||||||
Mock.Of<IControllerFactory>(),
|
Mock.Of<IControllerFactory>(),
|
||||||
|
|
@ -1408,7 +1408,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Func<object, int> method = x => 1;
|
Func<object, int> method = x => 1;
|
||||||
var actionDescriptor = new ReflectedActionDescriptor
|
var actionDescriptor = new ControllerActionDescriptor
|
||||||
{
|
{
|
||||||
MethodInfo = method.Method,
|
MethodInfo = method.Method,
|
||||||
Parameters = new List<ParameterDescriptor>
|
Parameters = new List<ParameterDescriptor>
|
||||||
|
|
@ -1446,7 +1446,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
var invoker = new ReflectedActionInvoker(actionContext,
|
var invoker = new ControllerActionInvoker(actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
||||||
Mock.Of<IControllerFactory>(),
|
Mock.Of<IControllerFactory>(),
|
||||||
|
|
@ -1467,7 +1467,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetActionArguments_NoInputFormatterFound_SetsModelStateError()
|
public async Task GetActionArguments_NoInputFormatterFound_SetsModelStateError()
|
||||||
{
|
{
|
||||||
var actionDescriptor = new ReflectedActionDescriptor
|
var actionDescriptor = new ControllerActionDescriptor
|
||||||
{
|
{
|
||||||
MethodInfo = typeof(TestController).GetTypeInfo().GetMethod("ActionMethodWithDefaultValues"),
|
MethodInfo = typeof(TestController).GetTypeInfo().GetMethod("ActionMethodWithDefaultValues"),
|
||||||
Parameters = new List<ParameterDescriptor>
|
Parameters = new List<ParameterDescriptor>
|
||||||
|
|
@ -1501,7 +1501,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
var invoker = new ReflectedActionInvoker(actionContext,
|
var invoker = new ControllerActionInvoker(actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
||||||
controllerFactory.Object,
|
controllerFactory.Object,
|
||||||
|
|
@ -1527,7 +1527,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public async Task Invoke_UsesDefaultValuesIfNotBound()
|
public async Task Invoke_UsesDefaultValuesIfNotBound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var actionDescriptor = new ReflectedActionDescriptor
|
var actionDescriptor = new ControllerActionDescriptor
|
||||||
{
|
{
|
||||||
MethodInfo = typeof(TestController).GetTypeInfo()
|
MethodInfo = typeof(TestController).GetTypeInfo()
|
||||||
.DeclaredMethods
|
.DeclaredMethods
|
||||||
|
|
@ -1569,7 +1569,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
var invoker = new ReflectedActionInvoker(actionContext,
|
var invoker = new ControllerActionInvoker(actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
||||||
controllerFactory.Object,
|
controllerFactory.Object,
|
||||||
|
|
@ -1625,16 +1625,16 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestReflectedActionInvoker : ReflectedActionInvoker
|
public class TestControllerActionInvoker : ControllerActionInvoker
|
||||||
{
|
{
|
||||||
private Mock<IControllerFactory> _factoryMock;
|
private Mock<IControllerFactory> _factoryMock;
|
||||||
|
|
||||||
public TestReflectedActionInvoker(
|
public TestControllerActionInvoker(
|
||||||
ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
IActionBindingContextProvider bindingContextProvider,
|
IActionBindingContextProvider bindingContextProvider,
|
||||||
INestedProviderManager<FilterProviderContext> filterProvider,
|
INestedProviderManager<FilterProviderContext> filterProvider,
|
||||||
Mock<IControllerFactory> controllerFactoryMock,
|
Mock<IControllerFactory> controllerFactoryMock,
|
||||||
ReflectedActionDescriptor descriptor,
|
ControllerActionDescriptor descriptor,
|
||||||
IInputFormattersProvider inputFormattersProvider,
|
IInputFormattersProvider inputFormattersProvider,
|
||||||
IBodyModelValidator bodyModelValidator) :
|
IBodyModelValidator bodyModelValidator) :
|
||||||
base(actionContext,
|
base(actionContext,
|
||||||
|
|
@ -97,12 +97,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
return await defaultActionSelector.SelectAsync(context);
|
return await defaultActionSelector.SelectAsync(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReflectedActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions)
|
private ControllerActionDescriptorProvider GetActionDescriptorProvider(DefaultActionDiscoveryConventions actionDiscoveryConventions)
|
||||||
{
|
{
|
||||||
var assemblies = new Assembly[] { typeof(DefaultActionDiscoveryConventionsActionSelectionTests).GetTypeInfo().Assembly, };
|
var assemblies = new Assembly[] { typeof(DefaultActionDiscoveryConventionsActionSelectionTests).GetTypeInfo().Assembly, };
|
||||||
var controllerAssemblyProvider = new Mock<IControllerAssemblyProvider>();
|
var controllerAssemblyProvider = new Mock<IControllerAssemblyProvider>();
|
||||||
controllerAssemblyProvider.SetupGet(x => x.CandidateAssemblies).Returns(assemblies);
|
controllerAssemblyProvider.SetupGet(x => x.CandidateAssemblies).Returns(assemblies);
|
||||||
return new ReflectedActionDescriptorProvider(
|
return new ControllerActionDescriptorProvider(
|
||||||
controllerAssemblyProvider.Object,
|
controllerAssemblyProvider.Object,
|
||||||
actionDiscoveryConventions,
|
actionDiscoveryConventions,
|
||||||
new TestGlobalFilterProvider(),
|
new TestGlobalFilterProvider(),
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
public void GetApiDescription_IgnoresActionWithoutApiExplorerData()
|
public void GetApiDescription_IgnoresActionWithoutApiExplorerData()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var action = new ReflectedActionDescriptor();
|
var action = new ControllerActionDescriptor();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var descriptions = GetApiDescriptions(action);
|
var descriptions = GetApiDescriptions(action);
|
||||||
|
|
@ -387,9 +387,9 @@ namespace Microsoft.AspNet.Mvc.Description
|
||||||
return formatters;
|
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.SetProperty(new ApiDescriptionActionData());
|
||||||
|
|
||||||
action.MethodInfo = GetType().GetMethod(
|
action.MethodInfo = GetType().GetMethod(
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<Person><Name>" + sampleName + "</Name></Person>";
|
"<Person><Name>" + sampleName + "</Name></Person>";
|
||||||
var modelStateDictionary = new ModelStateDictionary();
|
var modelStateDictionary = new ModelStateDictionary();
|
||||||
var invoker = GetReflectedActionInvoker(
|
var invoker = GetControllerActionInvoker(
|
||||||
input, typeof(Person), new XmlSerializerInputFormatter(), "application/xml");
|
input, typeof(Person), new XmlSerializerInputFormatter(), "application/xml");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<User><Name>" + sampleName + "</Name><UserName>" + sampleUserName + "</UserName></User>";
|
"<User><Name>" + sampleName + "</Name><UserName>" + sampleUserName + "</UserName></User>";
|
||||||
var modelStateDictionary = new ModelStateDictionary();
|
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
|
// Act
|
||||||
var result = await invoker.GetActionArguments(modelStateDictionary);
|
var result = await invoker.GetActionArguments(modelStateDictionary);
|
||||||
|
|
@ -76,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
|
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
|
||||||
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
|
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
|
||||||
var modelStateDictionary = new ModelStateDictionary();
|
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
|
// Act
|
||||||
var result = await invoker.GetActionArguments(modelStateDictionary);
|
var result = await invoker.GetActionArguments(modelStateDictionary);
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
|
var input = "{'Users': [{Name : '" + sampleFirstUser + "', UserName: '" + sampleFirstUserName +
|
||||||
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
|
"'}, {Name: '" + sampleSecondUser + "', UserName: '" + sampleSecondUserName + "'}]}";
|
||||||
var modelStateDictionary = new ModelStateDictionary();
|
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
|
// Act
|
||||||
var result = await invoker.GetActionArguments(modelStateDictionary);
|
var result = await invoker.GetActionArguments(modelStateDictionary);
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
Assert.Equal(sampleSecondUserName, model.Users[1].UserName);
|
Assert.Equal(sampleSecondUserName, model.Users[1].UserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReflectedActionInvoker GetReflectedActionInvoker(
|
private static ControllerActionInvoker GetControllerActionInvoker(
|
||||||
string input, Type parameterType, IInputFormatter selectedFormatter, string contentType)
|
string input, Type parameterType, IInputFormatter selectedFormatter, string contentType)
|
||||||
{
|
{
|
||||||
var mvcOptions = new MvcOptions();
|
var mvcOptions = new MvcOptions();
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
accessor.Object, Mock.Of<ITypeActivator>(), Mock.Of<IServiceProvider>());
|
accessor.Object, Mock.Of<ITypeActivator>(), Mock.Of<IServiceProvider>());
|
||||||
|
|
||||||
Func<object, int> method = x => 1;
|
Func<object, int> method = x => 1;
|
||||||
var actionDescriptor = new ReflectedActionDescriptor
|
var actionDescriptor = new ControllerActionDescriptor
|
||||||
{
|
{
|
||||||
MethodInfo = method.Method,
|
MethodInfo = method.Method,
|
||||||
Parameters = new List<ParameterDescriptor>
|
Parameters = new List<ParameterDescriptor>
|
||||||
|
|
@ -173,7 +173,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
var inputFormattersProvider = new Mock<IInputFormattersProvider>();
|
||||||
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
inputFormattersProvider.SetupGet(o => o.InputFormatters)
|
||||||
.Returns(new List<IInputFormatter>());
|
.Returns(new List<IInputFormatter>());
|
||||||
return new ReflectedActionInvoker(actionContext,
|
return new ControllerActionInvoker(actionContext,
|
||||||
actionBindingContextProvider.Object,
|
actionBindingContextProvider.Object,
|
||||||
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
Mock.Of<INestedProviderManager<FilterProviderContext>>(),
|
||||||
Mock.Of<IControllerFactory>(),
|
Mock.Of<IControllerFactory>(),
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
var controllerType = typeof(HomeController);
|
var controllerType = typeof(HomeController);
|
||||||
var actionMethod = controllerType.GetMethod("Index");
|
var actionMethod = controllerType.GetMethod("Index");
|
||||||
|
|
||||||
var action = new ReflectedActionDescriptor();
|
var action = new ControllerActionDescriptor();
|
||||||
action.DisplayName = "Microsoft.AspNet.Mvc.Routing.AttributeRoutingTest+HomeController.Index";
|
action.DisplayName = "Microsoft.AspNet.Mvc.Routing.AttributeRoutingTest+HomeController.Index";
|
||||||
action.MethodInfo = actionMethod;
|
action.MethodInfo = actionMethod;
|
||||||
action.RouteConstraints = new List<RouteDataActionConstraint>()
|
action.RouteConstraints = new List<RouteDataActionConstraint>()
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ using System.Net;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
{
|
{
|
||||||
public class ReflectedModelTest
|
public class ApplicationModelTest
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ReflectedModelWebSite));
|
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ApplicationModelWebSite));
|
||||||
private readonly Action<IApplicationBuilder> _app = new ReflectedModelWebSite.Startup().Configure;
|
private readonly Action<IApplicationBuilder> _app = new ApplicationModelWebSite.Startup().Configure;
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ControllerModel_CustomizedWithAttribute()
|
public async Task ControllerModel_CustomizedWithAttribute()
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.GetAsync("http://localhost/ReflectedActionModel/ActionName");
|
var response = await client.GetAsync("http://localhost/ActionModel/ActionName");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.GetAsync("http://localhost/ReflectedParameterModel/GetParameterIsOptional");
|
var response = await client.GetAsync("http://localhost/ParameterModel/GetParameterIsOptional");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"AddServicesWebSite": "1.0.0",
|
"AddServicesWebSite": "1.0.0",
|
||||||
"AntiForgeryWebSite": "1.0.0",
|
"AntiForgeryWebSite": "1.0.0",
|
||||||
"ApiExplorerWebSite": "1.0.0",
|
"ApiExplorerWebSite": "1.0.0",
|
||||||
|
"ApplicationModelWebSite": "1.0.0",
|
||||||
"BasicWebSite": "1.0.0",
|
"BasicWebSite": "1.0.0",
|
||||||
"CompositeViewEngine": "1.0.0",
|
"CompositeViewEngine": "1.0.0",
|
||||||
"ConnegWebSite": "1.0.0",
|
"ConnegWebSite": "1.0.0",
|
||||||
|
|
@ -17,7 +18,6 @@
|
||||||
"VersioningWebSite": "1.0.0",
|
"VersioningWebSite": "1.0.0",
|
||||||
"ModelBindingWebSite": "1.0.0",
|
"ModelBindingWebSite": "1.0.0",
|
||||||
"MvcSample.Web": "1.0.0",
|
"MvcSample.Web": "1.0.0",
|
||||||
"ReflectedModelWebSite": "1.0.0",
|
|
||||||
"RoutingWebSite": "1.0.0",
|
"RoutingWebSite": "1.0.0",
|
||||||
"RazorWebSite": "1.0.0",
|
"RazorWebSite": "1.0.0",
|
||||||
"RazorInstrumentationWebsite": "1.0.0",
|
"RazorInstrumentationWebsite": "1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.ReflectedModelBuilder;
|
using Microsoft.AspNet.Mvc.ApplicationModel;
|
||||||
|
|
||||||
namespace ApiExplorer
|
namespace ApiExplorer
|
||||||
{
|
{
|
||||||
// Disables ApiExplorer for a specific controller type.
|
// Disables ApiExplorer for a specific controller type.
|
||||||
// This is part of the test that validates that ApiExplorer can be configured via
|
// This is part of the test that validates that ApiExplorer can be configured via
|
||||||
// convention
|
// convention
|
||||||
public class ApiExplorerVisibilityDisabledConvention : IReflectedApplicationModelConvention
|
public class ApiExplorerVisibilityDisabledConvention : IGlobalModelConvention
|
||||||
{
|
{
|
||||||
private readonly TypeInfo _type;
|
private readonly TypeInfo _type;
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace ApiExplorer
|
||||||
_type = type.GetTypeInfo();
|
_type = type.GetTypeInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(ReflectedApplicationModel model)
|
public void Apply(GlobalModel model)
|
||||||
{
|
{
|
||||||
foreach (var controller in model.Controllers)
|
foreach (var controller in model.Controllers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// 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.
|
// 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
|
namespace ApiExplorer
|
||||||
{
|
{
|
||||||
// Enables ApiExplorer for controllers that haven't explicitly configured it.
|
// Enables ApiExplorer for controllers that haven't explicitly configured it.
|
||||||
// This is part of the test that validates that ApiExplorer can be configured via
|
// This is part of the test that validates that ApiExplorer can be configured via
|
||||||
// convention
|
// 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)
|
foreach (var controller in model.Controllers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>c2ef54f8-8886-4260-a322-44f76245f95d</ProjectGuid>
|
<ProjectGuid>cae52cb7-0fac-4b5b-8251-b0ff837db657</ProjectGuid>
|
||||||
<OutputType>Web</OutputType>
|
<OutputType>Web</OutputType>
|
||||||
<RootNamespace>ReflectedModelWebSite</RootNamespace>
|
<RootNamespace>ReflectedModelWebSite</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -3,23 +3,23 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc;
|
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
|
// This controller uses an reflected model attribute to change an action name, and thus
|
||||||
// the URL.
|
// the URL.
|
||||||
public class ReflectedActionModelController : Controller
|
public class ActionModelController : Controller
|
||||||
{
|
{
|
||||||
[ActionName2("ActionName")]
|
[ActionName2("ActionName")]
|
||||||
public string GetActionName()
|
public string GetActionName()
|
||||||
{
|
{
|
||||||
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
|
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
|
||||||
|
|
||||||
return actionDescriptor.Name;
|
return actionDescriptor.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActionName2Attribute : Attribute, IReflectedActionModelConvention
|
private class ActionName2Attribute : Attribute, IActionModelConvention
|
||||||
{
|
{
|
||||||
private readonly string _actionName;
|
private readonly string _actionName;
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace ReflectedModelWebSite
|
||||||
_actionName = actionName;
|
_actionName = actionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(ReflectedActionModel model)
|
public void Apply(ActionModel model)
|
||||||
{
|
{
|
||||||
model.ActionName = _actionName;
|
model.ActionName = _actionName;
|
||||||
}
|
}
|
||||||
|
|
@ -3,23 +3,23 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc;
|
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
|
// This controller uses an reflected model attribute to change the controller name, and thus
|
||||||
// the URL.
|
// the URL.
|
||||||
[ControllerName("CoolController")]
|
[ControllerName("CoolController")]
|
||||||
public class ReflectedControllerModelController : Controller
|
public class ControllerModelController : Controller
|
||||||
{
|
{
|
||||||
public string GetControllerName()
|
public string GetControllerName()
|
||||||
{
|
{
|
||||||
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
|
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
|
||||||
|
|
||||||
return actionDescriptor.ControllerName;
|
return actionDescriptor.ControllerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControllerNameAttribute : Attribute, IReflectedControllerModelConvention
|
private class ControllerNameAttribute : Attribute, IControllerModelConvention
|
||||||
{
|
{
|
||||||
private readonly string _controllerName;
|
private readonly string _controllerName;
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace ReflectedModelWebSite
|
||||||
_controllerName = controllerName;
|
_controllerName = controllerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(ReflectedControllerModel model)
|
public void Apply(ControllerModel model)
|
||||||
{
|
{
|
||||||
model.ControllerName = _controllerName;
|
model.ControllerName = _controllerName;
|
||||||
}
|
}
|
||||||
|
|
@ -3,23 +3,23 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc;
|
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.
|
// 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)
|
public string GetParameterIsOptional([Optional] int? id)
|
||||||
{
|
{
|
||||||
var actionDescriptor = (ReflectedActionDescriptor)ActionContext.ActionDescriptor;
|
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
|
||||||
|
|
||||||
return actionDescriptor.Parameters[0].IsOptional.ToString();
|
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;
|
model.IsOptional = true;
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
||||||
namespace ReflectedModelWebSite
|
namespace ApplicationModelWebSite
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +22,7 @@ namespace BasicWebSite
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ReflectedActionDescriptorProvider.DefaultOrder - 100;
|
return ControllerActionDescriptorProvider.DefaultOrder - 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace RoutingWebSite
|
||||||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||||
|
|
||||||
action = _actionContext.ActionDescriptor.Name,
|
action = _actionContext.ActionDescriptor.Name,
|
||||||
controller = ((ReflectedActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
||||||
|
|
||||||
link,
|
link,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace VersioningWebSite
|
||||||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||||
|
|
||||||
action = _actionContext.ActionDescriptor.Name,
|
action = _actionContext.ActionDescriptor.Name,
|
||||||
controller = ((ReflectedActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
||||||
|
|
||||||
link,
|
link,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue