Example #1
0
        private static OperationHandlerInfo[] GenerateHandlerInfo(List <HttpOperationHandler> handlers, List <HttpParameterBinding> bindings, string operationName, out int pipelineValuesArraySize)
        {
            Fx.Assert(handlers != null, "The 'handlers' parameter should not be null.");
            Fx.Assert(bindings != null, "The 'bindings' parameter should not be null.");
            Fx.Assert(operationName != null, "The 'bindings' parameter should not be null.");

            pipelineValuesArraySize = 0;
            OperationHandlerInfo[] handlerInfo = new OperationHandlerInfo[handlers.Count];

            // First, construct the OperationHandlerInfo[] to determine each handlers's offset
            //  in the pipelineValuesArray.
            for (int handlerIndex = 0; handlerIndex < handlers.Count; handlerIndex++)
            {
                HttpOperationHandler handler = handlers[handlerIndex];
                OperationHandlerInfo info    = new OperationHandlerInfo(pipelineValuesArraySize, handler);
                handlerInfo[handlerIndex] = info;
                pipelineValuesArraySize  += info.HandlerInputCount;

                handlers[handlerIndex].OperationName = operationName;
            }

            // Second, map the HttpParameterBindings into the OutputParameterInfo array indices.
            for (int handlerIndex = 0; handlerIndex < handlers.Count; handlerIndex++)
            {
                HttpOperationHandler handler = handlers[handlerIndex];

                for (int paramIndex = 0; paramIndex < handler.OutputParameters.Count; paramIndex++)
                {
                    OperationHandlerInfo info = handlerInfo[handlerIndex];
                    info.OutputParameterInfo[paramIndex] = new OutputParameterInfo(
                        bindings.Where(binding => binding.OutputHandlerIndex == handlerIndex &&
                                       binding.OutputParameterIndex == paramIndex)
                        .Select(binding => handlerInfo[binding.InputHandlerIndex].PipelineValuesOffset +
                                binding.InputParameterIndex));
                }
            }

            return(handlerInfo);
        }
        private static OperationHandlerInfo[] GenerateHandlerInfo(List<HttpOperationHandler> handlers, List<HttpParameterBinding> bindings, string operationName, out int pipelineValuesArraySize)
        {
            Fx.Assert(handlers != null, "The 'handlers' parameter should not be null.");
            Fx.Assert(bindings != null, "The 'bindings' parameter should not be null.");
            Fx.Assert(operationName != null, "The 'bindings' parameter should not be null.");

            pipelineValuesArraySize = 0;
            OperationHandlerInfo[] handlerInfo = new OperationHandlerInfo[handlers.Count];

            // First, construct the OperationHandlerInfo[] to determine each handlers's offset
            //  in the pipelineValuesArray.
            for (int handlerIndex = 0; handlerIndex < handlers.Count; handlerIndex++)
            {
                HttpOperationHandler handler = handlers[handlerIndex];
                OperationHandlerInfo info = new OperationHandlerInfo(pipelineValuesArraySize, handler);
                handlerInfo[handlerIndex] = info;
                pipelineValuesArraySize += info.HandlerInputCount;

                handlers[handlerIndex].OperationName = operationName;
            }

            // Second, map the HttpParameterBindings into the OutputParameterInfo array indices.
            for (int handlerIndex = 0; handlerIndex < handlers.Count; handlerIndex++)
            {
                HttpOperationHandler handler = handlers[handlerIndex];

                for (int paramIndex = 0; paramIndex < handler.OutputParameters.Count; paramIndex++)
                {
                    OperationHandlerInfo info = handlerInfo[handlerIndex];
                    info.OutputParameterInfo[paramIndex] = new OutputParameterInfo(
                        bindings.Where(binding => binding.OutputHandlerIndex == handlerIndex &&
                                                   binding.OutputParameterIndex == paramIndex)
                                .Select(binding => handlerInfo[binding.InputHandlerIndex].PipelineValuesOffset +
                                                    binding.InputParameterIndex));
                }
            }

            return handlerInfo;
        }