Esempio n. 1
0
        protected override async Task <IActionResult> InvokeActionAsync(ActionExecutingContext actionExecutingContext)
        {
            if (actionExecutingContext == null)
            {
                throw new ArgumentNullException(nameof(actionExecutingContext));
            }

            var actionMethodInfo = _descriptor.MethodInfo;

            var methodExecutor = GetControllerActionMethodExecutor();

            var arguments = ControllerActionExecutor.PrepareArguments(
                actionExecutingContext.ActionArguments,
                actionMethodInfo.GetParameters());

            Logger.ActionMethodExecuting(actionExecutingContext, arguments);

            var actionReturnValue = await ControllerActionExecutor.ExecuteAsync(
                methodExecutor,
                actionExecutingContext.Controller,
                arguments);

            var actionResult = CreateActionResult(
                actionMethodInfo.ReturnType,
                actionReturnValue);

            Logger.ActionMethodExecuted(actionExecutingContext, actionResult);

            return(actionResult);
        }
        private async Task <object> ExecuteAction(
            Delegate methodDelegate,
            TestController controller,
            object[] actionParameters)
        {
            var executor = ObjectMethodExecutor.Create(methodDelegate.GetMethodInfo(), _controller.GetType().GetTypeInfo());

            var result = await ControllerActionExecutor.ExecuteAsync(
                executor,
                controller,
                actionParameters);

            return(result);
        }