Example #1
0
        /// <summary>
        /// 发送到Bus并且同步执行该请求
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static TResult SendBusAndAction <TResult>(Message parameter)
        {
            //根据请求Key获取该请求所对应的服务处理句柄
            ServiceOperationHandler handler = ServiceRouting.GlobalRouting.GetRequestOperationHandler(parameter.Header.RequestKey);
            //使用参数带出返回值
            object result = null;

            //执行远程服务
            handler(parameter.Body, ref result);
            if (result == null)
            {
                return(default(TResult));
            }
            return((TResult)result);
        }
Example #2
0
        /// <summary>
        /// 发送到Bus并且同步执行该亲求
        /// </summary>
        /// <typeparam name="TResult">返回参数类型</typeparam>
        /// <param name="parmeter">参数实例</param>
        /// <returns></returns>
        public static Request SendBusAndAction(Request parmeter)
        {
            //首先根据请求key所获取该请求对应的服务处理句柄
            ServiceOperationHandler handler = ServiceRouting.GlobalRouting.GetRequestOperationHandle(parmeter.Head["RequestKey"]);
            //使用参数带出返回值
            Request result = null;

            //parmeter.AddService?.Invoke();
            if (handler == null)
            {
                return(null);
            }
            handler(parmeter, ref result);
            if (result == null)
            {
                return(null);
            }
            return(result);
        }
Example #3
0
        internal OperationHandlerPipelineInfo(
            IEnumerable <HttpOperationHandler> requestHandlers,
            IEnumerable <HttpOperationHandler> responseHandlers,
            HttpOperationDescription operation)
        {
            if (requestHandlers == null)
            {
                throw Fx.Exception.ArgumentNull("requestHandlers");
            }

            if (responseHandlers == null)
            {
                throw Fx.Exception.ArgumentNull("responseHandlers");
            }

            if (operation == null)
            {
                throw Fx.Exception.ArgumentNull("operation");
            }

            this.serviceOperationHandler = new ServiceOperationHandler(operation);

            List <HttpOperationHandler> handlers = new List <HttpOperationHandler>();

            handlers.Add(requestMessageSourceHandler);
            handlers.AddRange(requestHandlers);

            this.serviceOperationIndex = handlers.Count;

            handlers.Add(this.serviceOperationHandler);
            handlers.AddRange(responseHandlers);
            handlers.Add(responseMessageSinkHandler);

            string operationName = string.IsNullOrWhiteSpace(operation.Name) ?
                                   SR.UnknownName : operation.Name;

            List <HttpParameterBinding> bindings = BindHandlers(handlers, operationName, this.serviceOperationIndex);

            this.operationHandlerInfo = GenerateHandlerInfo(handlers, bindings, operationName, out this.pipelineValuesArraySize);
        }
        internal OperationHandlerPipelineInfo(
            IEnumerable<HttpOperationHandler> requestHandlers,
            IEnumerable<HttpOperationHandler> responseHandlers,
            HttpOperationDescription operation)
        {
            if (requestHandlers == null)
            {
                throw Fx.Exception.ArgumentNull("requestHandlers");
            }

            if (responseHandlers == null)
            {
                throw Fx.Exception.ArgumentNull("responseHandlers");
            }

            if (operation == null)
            {
                throw Fx.Exception.ArgumentNull("operation");
            }

            this.serviceOperationHandler = new ServiceOperationHandler(operation);

            List<HttpOperationHandler> handlers = new List<HttpOperationHandler>();
            handlers.Add(requestMessageSourceHandler);
            handlers.AddRange(requestHandlers);

            this.serviceOperationIndex = handlers.Count;

            handlers.Add(this.serviceOperationHandler);
            handlers.AddRange(responseHandlers);
            handlers.Add(responseMessageSinkHandler);

            string operationName = string.IsNullOrWhiteSpace(operation.Name) ?
                SR.UnknownName : operation.Name;

            List<HttpParameterBinding> bindings = BindHandlers(handlers, operationName, this.serviceOperationIndex);

            this.operationHandlerInfo = GenerateHandlerInfo(handlers, bindings, operationName, out this.pipelineValuesArraySize);
        }