/// <summary>
        /// Executes the receive pipeline
        /// </summary>
        /// <param name="inputMessage">Input message to feed to the pipeline</param>
        /// <returns>A collection of messages that were generated by the pipeline</returns>
        public MessageCollection Execute(IBaseMessage inputMessage)
        {
            if (inputMessage == null)
            {
                throw new ArgumentNullException("inputMessage");
            }

            Pipeline.InputMessages.Add(inputMessage);
            MessageCollection output = new MessageCollection();

            Pipeline.Execute(Context);

            IBaseMessage om = null;

            while ((om = Pipeline.GetNextOutputMessage(Context)) != null)
            {
                output.Add(om);
                // we have to consume the entire stream for the body part.
                // Otherwise, the disassembler might enter an infinite loop.
                // We currently copy the output into a new memory stream
                if (om.BodyPart != null && om.BodyPart.Data != null)
                {
                    om.BodyPart.Data = CopyStream(om.BodyPart.Data);
                }
            }

            return(output);
        }