private static bool CanSupportDynamicProxy(IActionInvoker actionInvoker) { var warnings = HttpContext.Current.GetWarnings(); if (actionInvoker is ControllerActionInvoker)//TODO: What changes for AsyncControllerActionInvoker? { //Make sure there is a parameterless constructor and the type is not sealed var actionInvokerType = actionInvoker.GetType(); var proxy = actionInvoker as IProxyTargetAccessor; var defaultConstructor = actionInvokerType.GetConstructor(new Type[] { }); var result = (!actionInvokerType.IsSealed && defaultConstructor != null && proxy == null); if (!result) { warnings.Add(new NotProxyableWarning(actionInvoker)); } return(result); } warnings.Add(new NotAControllerActionInvokerWarning(actionInvoker)); return(false); }
internal static bool CanSupportDynamicProxy(this IActionInvoker actionInvoker, IGlimpseLogger logger) { if (actionInvoker is ControllerActionInvoker)//TODO: What changes for AsyncControllerActionInvoker? { //Make sure there is a parameterless constructor and the type is not sealed var actionInvokerType = actionInvoker.GetType(); var proxy = actionInvoker as IProxyTargetAccessor; var defaultConstructor = actionInvokerType.GetConstructor(new Type[] { }); var result = (!actionInvokerType.IsSealed && defaultConstructor != null && proxy == null); if (!result) { //TODO: Add logging } return(result); } //logger.Warn(actionInvoker.GetType() + " is not a System.Web.Mvc.ControllerActionInvoker."); //TODO add logging warnings.Add(new NotAControllerActionInvokerWarning(actionInvoker)); return(false); }
public void ActionInvokerProperty() { // Arrange EmptyController controller = new EmptyController(); // Act IActionInvoker invoker = controller.ActionInvoker; // Assert Assert.AreEqual(typeof(AsyncControllerActionInvoker), invoker.GetType()); }
private IEnumerable <ActionDescriptor> GetActionDescriptors(Controller controller) { ControllerContext.Controller = controller; IActionInvoker actionInvoker = controller.ActionInvoker; MethodInfo method = actionInvoker.GetType().GetMethod("GetControllerDescriptor", BindingFlags.Instance | BindingFlags.NonPublic); ControllerDescriptor controllerDescriptor = (ControllerDescriptor)method.Invoke(actionInvoker, new object[] { ControllerContext }); string[] actionNames = new string[] { "Foo", "FooAsync", "FooCompleted", "Bar" }; foreach (string actionName in actionNames) { ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(ControllerContext, actionName); if (null != actionDescriptor) { yield return(actionDescriptor); } } }
private static bool CanSupportDynamicProxy(IActionInvoker actionInvoker) { var warnings = HttpContext.Current.GetWarnings(); if (actionInvoker is ControllerActionInvoker)//TODO: What changes for AsyncControllerActionInvoker? { //Make sure there is a parameterless constructor and the type is not sealed var actionInvokerType = actionInvoker.GetType(); var proxy = actionInvoker as IProxyTargetAccessor; var defaultConstructor = actionInvokerType.GetConstructor(new Type[] { }); var result = (!actionInvokerType.IsSealed && defaultConstructor != null && proxy == null); if (!result) warnings.Add(new NotProxyableWarning(actionInvoker)); return result; } warnings.Add(new NotAControllerActionInvokerWarning(actionInvoker)); return false; }
public NotAControllerActionInvokerWarning(IActionInvoker actionInvoker) { Message = actionInvoker.GetType() + " is not a System.Web.Mvc.ControllerActionInvoker."; }