コード例 #1
0
		public static ReflectedActionDescriptor CreateDescriptor(MethodInfo method,
			string name, ControllerDescriptor controller)
		{
			ReflectedActionDescriptor descriptor = new ReflectedActionDescriptor(method, name, controller, false);
			ValidateActionMethod(method);

			return descriptor;
		}
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 public ReflectedActionDescriptor(MethodInfo method, string name, 
     ControllerDescriptor controller)
     : this(method, name, controller, true)
 {
 }
コード例 #6
0
 public ReflectedActionDescriptor(MethodInfo method, string name,
                                  ControllerDescriptor controller)
     : this(method, name, controller, true)
 {
 }
コード例 #7
0
 protected virtual ActionDescriptor FindAction(ControllerContext context, 
     ControllerDescriptor descriptor, string actionName)
 {
     return descriptor.FindAction(context, actionName);
 }
コード例 #8
0
 protected virtual ActionDescriptor FindAction(ControllerContext context,
                                               ControllerDescriptor descriptor, string actionName)
 {
     return(descriptor.FindAction(context, actionName));
 }