Renames to prepare for action selection PR

This commit is contained in:
Yishai Galatzer 2014-02-16 11:10:21 -08:00
parent 90daa2587d
commit 1d40372cc3
11 changed files with 38 additions and 32 deletions

View File

@ -12,10 +12,11 @@ namespace Microsoft.AspNet.Mvc.Razor
"/Views/{1}/{0}.cshtml", "/Views/{1}/{0}.cshtml",
"/Views/Shared/{0}.cshtml", "/Views/Shared/{0}.cshtml",
}; };
private readonly IRouteContextProvider _actionDescriptorProvider;
private readonly IActionDescriptorProvider _actionDescriptorProvider;
private readonly IVirtualPathViewFactory _virtualPathFactory; private readonly IVirtualPathViewFactory _virtualPathFactory;
public RazorViewEngine(IRouteContextProvider actionDescriptorProvider, public RazorViewEngine(IActionDescriptorProvider actionDescriptorProvider,
IVirtualPathViewFactory virtualPathFactory) IVirtualPathViewFactory virtualPathFactory)
{ {
_actionDescriptorProvider = actionDescriptorProvider; _actionDescriptorProvider = actionDescriptorProvider;
@ -29,7 +30,9 @@ namespace Microsoft.AspNet.Mvc.Razor
public async Task<ViewEngineResult> FindView(RequestContext requestContext, string viewName) public async Task<ViewEngineResult> FindView(RequestContext requestContext, string viewName)
{ {
var actionDescriptor = _actionDescriptorProvider.CreateDescriptor(requestContext) as ControllerActionRouteContext; // TODO: We plan to change this on the next CR, so we don't have a strong depenedency directly on the specific
// type of the action descriptor
var actionDescriptor = _actionDescriptorProvider.CreateDescriptor(requestContext) as TypeMethodBasedActionDescriptor;
if (actionDescriptor == null) if (actionDescriptor == null)
{ {

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.Startup
Add<IActionInvokerFactory, ActionInvokerFactory>(); Add<IActionInvokerFactory, ActionInvokerFactory>();
Add<IActionResultHelper, ActionResultHelper>(); Add<IActionResultHelper, ActionResultHelper>();
Add<IActionResultFactory, ActionResultFactory>(); Add<IActionResultFactory, ActionResultFactory>();
Add<IRouteContextProvider, ControllerActionBasedRouteContextProvider>(); Add<IActionDescriptorProvider, TypeMethodBasedActionDescriptorProvider>();
Add<IActionInvokerProvider, ActionInvokerProvider>(); Add<IActionInvokerProvider, ActionInvokerProvider>();
// need singleton support here. // need singleton support here.

View File

@ -7,10 +7,10 @@ namespace Microsoft.AspNet.Mvc
{ {
private readonly IActionResultFactory _actionResultFactory; private readonly IActionResultFactory _actionResultFactory;
private readonly IActionInvokerProvider _actionInvokerProvider; private readonly IActionInvokerProvider _actionInvokerProvider;
private readonly IRouteContextProvider _routeContextProvider; private readonly IActionDescriptorProvider _routeContextProvider;
public ActionInvokerFactory(IActionResultFactory actionResultFactory, public ActionInvokerFactory(IActionResultFactory actionResultFactory,
IRouteContextProvider actionDescriptorProvider, IActionDescriptorProvider actionDescriptorProvider,
IActionInvokerProvider actionInvokerProvider) IActionInvokerProvider actionInvokerProvider)
{ {
_actionResultFactory = actionResultFactory; _actionResultFactory = actionResultFactory;
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc
public IActionInvoker CreateInvoker(RequestContext requestContext) public IActionInvoker CreateInvoker(RequestContext requestContext)
{ {
RouteContext routeContext = _routeContextProvider.CreateDescriptor(requestContext); ActionDescriptor routeContext = _routeContextProvider.CreateDescriptor(requestContext);
if (routeContext == null) if (routeContext == null)
{ {
return null; return null;

View File

@ -18,15 +18,15 @@ namespace Microsoft.AspNet.Mvc
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public IActionInvoker GetInvoker(RequestContext requestContext, RouteContext routeContext) public IActionInvoker GetInvoker(RequestContext requestContext, ActionDescriptor actionDescriptor)
{ {
var controllerActionDescriptor = routeContext as ControllerActionRouteContext; var ad = actionDescriptor as TypeMethodBasedActionDescriptor;
if (controllerActionDescriptor != null) if (ad != null)
{ {
return new ControllerActionInvoker( return new TypeMethodBasedActionInvoker(
requestContext, requestContext,
controllerActionDescriptor, ad,
_actionResultFactory, _actionResultFactory,
_controllerFactory, _controllerFactory,
_serviceProvider); _serviceProvider);

View File

@ -1,9 +0,0 @@
namespace Microsoft.AspNet.Mvc
{
public class ControllerActionRouteContext : RouteContext
{
public string ControllerName { get; set; }
public string ActionName { get; set; }
}
}

View File

@ -2,8 +2,8 @@
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public interface IRouteContextProvider public interface IActionDescriptorProvider
{ {
RouteContext CreateDescriptor(RequestContext requestContext); ActionDescriptor CreateDescriptor(RequestContext requestContext);
} }
} }

View File

@ -3,6 +3,6 @@ namespace Microsoft.AspNet.Mvc
{ {
public interface IActionInvokerProvider public interface IActionInvokerProvider
{ {
IActionInvoker GetInvoker(RequestContext requestContext, RouteContext routeContext); IActionInvoker GetInvoker(RequestContext requestContext, ActionDescriptor routeContext);
} }
} }

View File

@ -1,6 +1,6 @@
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public class RouteContext public class ActionDescriptor
{ {
} }
} }

View File

@ -0,0 +1,12 @@
namespace Microsoft.AspNet.Mvc
{
public class TypeMethodBasedActionDescriptor : ActionDescriptor
{
// TODO:
// In the next PR the content of the descriptor is changing, and the string below will
// be represented as route constraints, so for now leaving as is.
public string ControllerName { get; set; }
public string ActionName { get; set; }
}
}

View File

@ -1,13 +1,13 @@
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public class ControllerActionBasedRouteContextProvider : IRouteContextProvider public class TypeMethodBasedActionDescriptorProvider : IActionDescriptorProvider
{ {
public RouteContext CreateDescriptor(RequestContext requestContext) public ActionDescriptor CreateDescriptor(RequestContext requestContext)
{ {
var controllerName = (string)requestContext.RouteValues["controller"]; var controllerName = (string)requestContext.RouteValues["controller"];
var actionName = (string)requestContext.RouteValues["action"]; var actionName = (string)requestContext.RouteValues["action"];
return new ControllerActionRouteContext return new TypeMethodBasedActionDescriptor()
{ {
ControllerName = controllerName, ControllerName = controllerName,
ActionName = actionName ActionName = actionName

View File

@ -6,16 +6,16 @@ using Microsoft.AspNet.Abstractions;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
public class ControllerActionInvoker : IActionInvoker public class TypeMethodBasedActionInvoker : IActionInvoker
{ {
private readonly RequestContext _requestContext; private readonly RequestContext _requestContext;
private readonly ControllerActionRouteContext _descriptor; private readonly TypeMethodBasedActionDescriptor _descriptor;
private readonly IActionResultFactory _actionResultFactory; private readonly IActionResultFactory _actionResultFactory;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly IControllerFactory _controllerFactory; private readonly IControllerFactory _controllerFactory;
public ControllerActionInvoker(RequestContext requestContext, public TypeMethodBasedActionInvoker(RequestContext requestContext,
ControllerActionRouteContext descriptor, TypeMethodBasedActionDescriptor descriptor,
IActionResultFactory actionResultFactory, IActionResultFactory actionResultFactory,
IControllerFactory controllerFactory, IControllerFactory controllerFactory,
IServiceProvider serviceProvider) IServiceProvider serviceProvider)