public object[] Bind <TMsg>(TMsg message, Delegate messageInitializer)
        {
            ParameterInfo[] destinationArguments = messageInitializer.Method.GetParameters();

            if (destinationArguments.Length == 0)
            {
                return new object[] {}
            }
            ;

            var argumentValues = new List <object> {
                message
            };

            if (destinationArguments[0].ParameterType != typeof(TMsg))
            {
                throw new InvalidOperationException("The first parameter of the delegate must be the message to initialize");
            }

            if (destinationArguments.Length > 1)
            {
                int requestOffset = 1;

                if (destinationArguments[1].ParameterType == typeof(object) && destinationArguments[1].Name == "body")
                {
                    requestOffset++;
                    argumentValues.Add(_request.NegotiateAndDeserializeMethodBody());
                }

                var mapper = new MapRequestToDelegateHeuristic(_routeOwningUrl.Route, messageInitializer, requestOffset);

                argumentValues.AddRange(mapper.Map(_request.Request));
            }
            return(argumentValues.ToArray());
        }
    }
 public ProduceDelegateReturnValue(Delegate returnValueProducer, MapRequestToDelegateHeuristic mapper)
 {
     _returnValueProducer = returnValueProducer;
     _mapper = mapper;
 }
 public ProduceDelegateReturnValue(Delegate returnValueProducer, MapRequestToDelegateHeuristic mapper)
 {
     _returnValueProducer = returnValueProducer;
     _mapper = mapper;
 }