private CloudQueueMessage SerializeMessage(TransportMessage message)
        {
            using (var stream = new MemoryStream())
            {

                if (message.Headers == null)
                    message.Headers = new Dictionary<string, string>();

                if (!message.Headers.ContainsKey(Idforcorrelation))
                    message.Headers.Add(Idforcorrelation, null);

                if (String.IsNullOrEmpty(message.Headers[Idforcorrelation]))
                    message.Headers[Idforcorrelation] = message.IdForCorrelation;

                var toSend = new MessageWrapper
                {
                    Id = message.Id,
                    Body = message.Body,
                    CorrelationId = message.CorrelationId,
                    Recoverable = message.Recoverable,
                    ReplyToAddress = message.ReplyToAddress.ToString(),
                    TimeToBeReceived = message.TimeToBeReceived,
                    Headers = message.Headers,
                    MessageIntent = message.MessageIntent,
                    TimeSent = message.TimeSent,
                    IdForCorrelation = message.IdForCorrelation
                };

                MessageSerializer.Serialize(new IMessage[] { toSend }, stream);
                return new CloudQueueMessage(stream.ToArray());
            }
        }
 private CloudQueueMessage SerializeMessage(TransportMessage message)
 {
     using (var stream = new MemoryStream())
     {
         //var formatter = new BinaryFormatter();
         //formatter.Serialize(stream, originalMessage);
         var toSend = new MessageWrapper
         {
             Id = message.Id,
             Body = message.Body,
             CorrelationId = message.CorrelationId,
             Recoverable = message.Recoverable,
             ReplyToAddress = message.ReplyToAddress,
             TimeToBeReceived = message.TimeToBeReceived,
             Headers = message.Headers,
             MessageIntent = message.MessageIntent,
             TimeSent = message.TimeSent,
             IdForCorrelation = message.IdForCorrelation
         };
         MessageSerializer.Serialize(new IMessage[] { toSend }, stream);
         return new CloudQueueMessage(stream.ToArray());
     }
 }
        private CloudQueueMessage SerializeMessage(TransportMessage message)
        {
            using (var stream = new MemoryStream())
            {
                var toSend = new MessageWrapper
                    {
                        Id = message.Id,
                        Body = message.Body,
                        CorrelationId = message.CorrelationId,
                        Recoverable = message.Recoverable,
                        ReplyToAddress = message.ReplyToAddress == null ? Address.Self.ToString() : message.ReplyToAddress.ToString(),
                        TimeToBeReceived = message.TimeToBeReceived,
                        Headers = message.Headers,
                        MessageIntent = message.MessageIntent
                    };

                MessageSerializer.Serialize(new IMessage[] { toSend }, stream);
                return new CloudQueueMessage(stream.ToArray());
            }
        }