Remove ControllerDescriptor and fix ControllerActionDescriptor to pick the right type for the display name.
This commit is contained in:
parent
de50d3dbf9
commit
2eef4dd3cf
|
|
@ -10,27 +10,21 @@ namespace Microsoft.AspNet.Mvc
|
|||
[DebuggerDisplay("CA {DisplayName}(RC-{RouteConstraints.Count})")]
|
||||
public class ControllerActionDescriptor : ActionDescriptor
|
||||
{
|
||||
public string ControllerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return ControllerDescriptor.Name;
|
||||
}
|
||||
}
|
||||
public string ControllerName { get; set; }
|
||||
|
||||
public MethodInfo MethodInfo { get; set; }
|
||||
|
||||
public ControllerDescriptor ControllerDescriptor { get; set; }
|
||||
public TypeInfo ControllerTypeInfo { get; set; }
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (base.DisplayName == null && MethodInfo != null)
|
||||
if (base.DisplayName == null && ControllerTypeInfo != null && MethodInfo != null)
|
||||
{
|
||||
base.DisplayName = string.Format(
|
||||
"{0}.{1}",
|
||||
MethodInfo.DeclaringType.FullName,
|
||||
ControllerTypeInfo.FullName,
|
||||
MethodInfo.Name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
foreach (var controller in application.Controllers)
|
||||
{
|
||||
var controllerDescriptor = new ControllerDescriptor()
|
||||
{
|
||||
ControllerTypeInfo = controller.ControllerType,
|
||||
Name = controller.ControllerName,
|
||||
};
|
||||
|
||||
foreach (var action in controller.Actions)
|
||||
{
|
||||
// Controllers with multiple [Route] attributes (or user defined implementation of
|
||||
|
|
@ -58,7 +52,8 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
foreach (var actionDescriptor in actionDescriptors)
|
||||
{
|
||||
actionDescriptor.ControllerDescriptor = controllerDescriptor;
|
||||
actionDescriptor.ControllerName = controller.ControllerName;
|
||||
actionDescriptor.ControllerTypeInfo = controller.ControllerType;
|
||||
|
||||
AddApiExplorerInfo(actionDescriptor, action, controller);
|
||||
AddRouteConstraints(actionDescriptor, controller, action);
|
||||
|
|
|
|||
|
|
@ -1,14 +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.
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public class ControllerDescriptor
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public TypeInfo ControllerTypeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
var controller = _typeActivator.CreateInstance(
|
||||
_serviceProvider,
|
||||
actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType());
|
||||
actionDescriptor.ControllerTypeInfo.AsType());
|
||||
|
||||
actionContext.Controller = controller;
|
||||
_controllerActivator.Activate(controller, actionContext);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace System.Web.Http
|
|||
|
||||
// Assert
|
||||
var controllerType = typeof(TestControllers.ProductsController).GetTypeInfo();
|
||||
var actions = results.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType).ToArray();
|
||||
var actions = results.Where(ad => ad.ControllerTypeInfo == controllerType).ToArray();
|
||||
|
||||
Assert.NotEmpty(actions);
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ namespace System.Web.Http
|
|||
|
||||
// Assert
|
||||
var controllerType = typeof(TestControllers.Blog).GetTypeInfo();
|
||||
var actions = results.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType).ToArray();
|
||||
var actions = results.Where(ad => ad.ControllerTypeInfo == controllerType).ToArray();
|
||||
|
||||
Assert.Empty(actions);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.MethodInfo.Name == "GetAll")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.MethodInfo.Name == "Edit")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.MethodInfo.Name == "Delete")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.MethodInfo.Name == "Options")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.ToArray();
|
||||
|
||||
Assert.NotEmpty(actions);
|
||||
|
|
@ -243,7 +243,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.StoreController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.ToArray();
|
||||
|
||||
Assert.NotEmpty(actions);
|
||||
|
|
@ -268,7 +268,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.Name == "Get")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.Name == "Put")
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ namespace System.Web.Http
|
|||
// Assert
|
||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||
var actions = results
|
||||
.Where(ad => ad.ControllerDescriptor.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||
.Where(ad => ad.Name == "Post")
|
||||
.ToArray();
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace RoutingWebSite
|
|||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||
|
||||
action = _actionContext.ActionDescriptor.Name,
|
||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
||||
|
||||
link,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace VersioningWebSite
|
|||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||
|
||||
action = _actionContext.ActionDescriptor.Name,
|
||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerDescriptor.Name,
|
||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
||||
|
||||
link,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue