internal HttpResponseMessage ExecuteResponsePipeline(OperationHandlerPipelineContext pipelineContext, object[] parameters, object result) { Fx.Assert(pipelineContext != null, "The 'pipelineContext' parameter should not be null."); Fx.Assert(parameters != null, "The 'parameters' parameter should not be null."); object[] pipelineParameters = new object[parameters.Length + 1]; pipelineParameters[0] = result; Array.Copy(parameters, 0, pipelineParameters, 1, parameters.Length); pipelineContext.SetOutputValuesAndAdvance(pipelineParameters); for (int handlerIndex = 0; handlerIndex < this.responseHandlersCount; handlerIndex++) { HttpOperationHandler handler = this.responseHandlers[handlerIndex]; object[] inputValues = pipelineContext.GetInputValues(); object[] outputValues = handler.Handle(inputValues); pipelineContext.SetOutputValuesAndAdvance(outputValues); } return(pipelineContext.GetHttpResponseMessage()); }
internal OperationHandlerPipelineContext ExecuteRequestPipeline(HttpRequestMessage request, object[] parameters) { Fx.Assert(request != null, "The 'request' parameter should not be null."); Fx.Assert(parameters != null, "The 'parameters' parameter should not be null."); OperationHandlerPipelineContext pipelineContext = new OperationHandlerPipelineContext(this.pipelineContextInfo, request); for (int handlerIndex = 0; handlerIndex < this.requestHandlersCount; handlerIndex++) { HttpOperationHandler handler = this.requestHandlers[handlerIndex]; object[] inputValues = pipelineContext.GetInputValues(); object[] outputValues = handler.Handle(inputValues); pipelineContext.SetOutputValuesAndAdvance(outputValues); } object[] pipelineParameters = pipelineContext.GetInputValues(); Fx.Assert(pipelineParameters.Length == parameters.Length, "The two parameter object arrays should have the same length."); Array.Copy(pipelineParameters, parameters, parameters.Length); return(pipelineContext); }
internal OperationHandlerPipelineContext ExecuteRequestPipeline(HttpRequestMessage request, object[] parameters) { Fx.Assert(request != null, "The 'request' parameter should not be null."); Fx.Assert(parameters != null, "The 'parameters' parameter should not be null."); OperationHandlerPipelineContext pipelineContext = new OperationHandlerPipelineContext(this.pipelineContextInfo, request); for (int handlerIndex = 0; handlerIndex < this.requestHandlersCount; handlerIndex++) { HttpOperationHandler handler = this.requestHandlers[handlerIndex]; object[] inputValues = pipelineContext.GetInputValues(); object[] outputValues = handler.Handle(inputValues); pipelineContext.SetOutputValuesAndAdvance(outputValues); } object[] pipelineParameters = pipelineContext.GetInputValues(); Fx.Assert(pipelineParameters.Length == parameters.Length, "The two parameter object arrays should have the same length."); Array.Copy(pipelineParameters, parameters, parameters.Length); return pipelineContext; }
public void SetOutputValuesAndAdvanceCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); int indexAtCall = -1; object[] valuesAtCall = null; object[] pipelineValuesAtCall = null; MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.SetOutputValuesFromHandlerInt32ObjectArrayObjectArray = (index, values, pipelineValues) => { indexAtCall = index; valuesAtCall = values; pipelineValuesAtCall = pipelineValues; }; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); context.SetOutputValuesAndAdvance(new object[0]); Assert.AreEqual(1, indexAtCall, "Handler index was not set."); Assert.IsNotNull(valuesAtCall, "Values were not set."); Assert.IsNotNull(pipelineValuesAtCall, "Pipeline values were not set."); }
internal HttpResponseMessage ExecuteResponsePipeline(OperationHandlerPipelineContext pipelineContext, object[] parameters, object result) { Fx.Assert(pipelineContext != null, "The 'pipelineContext' parameter should not be null."); Fx.Assert(parameters != null, "The 'parameters' parameter should not be null."); object[] pipelineParameters = new object[parameters.Length + 1]; pipelineParameters[0] = result; Array.Copy(parameters, 0, pipelineParameters, 1, parameters.Length); pipelineContext.SetOutputValuesAndAdvance(pipelineParameters); for (int handlerIndex = 0; handlerIndex < this.responseHandlersCount; handlerIndex++) { HttpOperationHandler handler = this.responseHandlers[handlerIndex]; object[] inputValues = pipelineContext.GetInputValues(); object[] outputValues = handler.Handle(inputValues); pipelineContext.SetOutputValuesAndAdvance(outputValues); } return pipelineContext.GetHttpResponseMessage(); }
public void SetOutputValuesAndAdvanceCallsPipelineInfo() { HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request }; HttpOperationHandler[] handlers = new HttpOperationHandler[0]; SHttpOperationDescription operation = new SHttpOperationDescription() { ReturnValue = HttpParameter.ResponseMessage }; OperationHandlerPipelineInfo pipelineInfo = new OperationHandlerPipelineInfo(handlers, handlers, operation); int indexAtCall = -1; object[] valuesAtCall = null; object[] pipelineValuesAtCall = null; MOperationHandlerPipelineInfo molePipelineInfo = new MOperationHandlerPipelineInfo(pipelineInfo); molePipelineInfo.GetEmptyPipelineValuesArray = () => new object[0]; molePipelineInfo.SetHttpRequestMessageHttpRequestMessageObjectArray = (req, values) => { }; molePipelineInfo.SetOutputValuesFromHandlerInt32ObjectArrayObjectArray = (index, values, pipelineValues) => { indexAtCall = index; valuesAtCall = values; pipelineValuesAtCall = pipelineValues; }; OperationHandlerPipelineContext context = new OperationHandlerPipelineContext(pipelineInfo, request); context.SetOutputValuesAndAdvance(new object[0]); Assert.AreEqual(1, indexAtCall, "Handler index was not set."); Assert.IsNotNull(valuesAtCall, "Values were not set."); Assert.IsNotNull(pipelineValuesAtCall, "Pipeline values were not set."); }