public static ReflectedActionDescriptor CreateDescriptor(MethodInfo method, string name, ControllerDescriptor controller) { ReflectedActionDescriptor descriptor = new ReflectedActionDescriptor(method, name, controller, false); ValidateActionMethod(method); return descriptor; }
public virtual bool InvokeAction(ControllerContext context, string actionName, IDictionary <string, object> values) { Precondition.Require(context, () => Error.ArgumentNull("context")); Precondition.Defined(actionName, () => Error.ArgumentNull("actionName")); ControllerDescriptor controller = GetControllerDescriptor(context); ActionDescriptor currentAction = FindAction(context, controller, actionName); if (currentAction == null) { return(false); } ActionFilterInfo filters = GetFilters(context, currentAction); try { context.Parameters.Merge(values); context.Parameters.Merge(GetParameterValues(context, currentAction)); AuthorizationContext authContext = InvokeAuthorizationFilters( context, currentAction, filters.AuthorizationFilters); if (authContext.Cancel) { InvokeActionResult(context, authContext.Result ?? EmptyResult.Instance); } else { if (context.Controller.ValidateRequest) { ValidateRequest(context.Context.Request); } ActionExecutedContext resultContext = InvokeActionFilters( context, currentAction, filters.ActionFilters); InvokeActionResultFilters(context, filters.ResultFilters, resultContext.Result); } } catch (Exception ex) { ExceptionContext exceptionContext = InvokeExceptionFilters(context, ex, filters.ExceptionFilters); if (!exceptionContext.Handled) { throw; } InvokeActionResult(context, exceptionContext.Result); } return(true); }
internal ReflectedActionDescriptor(MethodInfo method, string name, ControllerDescriptor controller, bool validateMethod) { Precondition.Require(method, () => Error.ArgumentNull("method")); Precondition.Defined(name, () => Error.ArgumentNull("name")); Precondition.Require(controller, () => Error.ArgumentNull("controller")); if (validateMethod) ValidateActionMethod(method); _method = method; _name = name; _controller = controller; }
internal ReflectedActionDescriptor(MethodInfo method, string name, ControllerDescriptor controller, bool validateMethod) { Precondition.Require(method, () => Error.ArgumentNull("method")); Precondition.Defined(name, () => Error.ArgumentNull("name")); Precondition.Require(controller, () => Error.ArgumentNull("controller")); if (validateMethod) { ValidateActionMethod(method); } _method = method; _name = name; _controller = controller; }
public ReflectedActionDescriptor(MethodInfo method, string name, ControllerDescriptor controller) : this(method, name, controller, true) { }
protected virtual ActionDescriptor FindAction(ControllerContext context, ControllerDescriptor descriptor, string actionName) { return descriptor.FindAction(context, actionName); }
protected virtual ActionDescriptor FindAction(ControllerContext context, ControllerDescriptor descriptor, string actionName) { return(descriptor.FindAction(context, actionName)); }