Beispiel #1
0
        private IAsyncResult BeginInvokeSynchronousActionMethod(
            ControllerContext controllerContext,
            ActionDescriptor actionDescriptor,
            IDictionary <string, object> parameters,
            AsyncCallback callback,
            object state
            )
        {
            // Frequently called so ensure delegate remains static and arguments do not allocate
            EndInvokeDelegate <ActionInvocation, ActionResult> endInvokeFunc = (
                asyncResult,
                innerInvokeState
                ) =>
            {
                return(innerInvokeState.InvokeSynchronousActionMethod());
            };
            ActionInvocation endInvokeState = new ActionInvocation(
                this,
                controllerContext,
                actionDescriptor,
                parameters
                );

            return(AsyncResultWrapper.BeginSynchronous(
                       callback,
                       state,
                       endInvokeFunc,
                       endInvokeState,
                       _invokeActionMethodTag
                       ));
        }
Beispiel #2
0
        /// <summary>
        /// 处理相应的请求处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        private void HttpServer_OnRequested(HttpRequest request, HttpResponse response)
        {
            string moduleName     = request.ModuleName;
            string controllerName = request.ControllerName;
            string actionName     = request.ActionName;
            Dictionary <string, string> parameters = request.Parameters;


            ActionInvocation actionInvocation = this.ModuleFramework.NewActionInvocation(moduleName);

            if (actionInvocation != null)
            {
                actionInvocation.Setup(controllerName, actionName, parameters);
                response.Body = JsonConvert.SerializeObject(actionInvocation.Invoke());
            }
            else
            {
                response.Body       = "系统里面找不到定义的{0}Action方法".FormatEx(actionName);
                response.StatusCode = System.Net.HttpStatusCode.NotFound;
            }
        }
 private IAsyncResult BeginInvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<string, object> parameters, AsyncCallback callback, object state)
 {
     // Frequently called so ensure delegate remains static and arguments do not allocate
     EndInvokeDelegate<ActionInvocation, ActionResult> endInvokeFunc = (asyncResult, innerInvokeState) =>
         {
             return innerInvokeState.InvokeSynchronousActionMethod();
         };
     ActionInvocation endInvokeState = new ActionInvocation(this, controllerContext, actionDescriptor, parameters);
     return AsyncResultWrapper.BeginSynchronous(callback, state, endInvokeFunc, endInvokeState, _invokeActionMethodTag);
 }
Beispiel #4
0
 public InvocationResult Invoke(ActionInvocation request)
 {
     return(new InvocationResult("RESULT", "OUTPUT"));
 }