ISendContext CreateMessageContext(Uri sourceAddress, Uri destinationAddress)
        {
            var context = new ScheduledMessageContext(Body);

            context.SetDestinationAddress(destinationAddress);
            context.SetSourceAddress(sourceAddress);
            context.SetResponseAddress(ToUri(ResponseAddress));
            context.SetFaultAddress(ToUri(FaultAddress));

            SetHeaders(context);
            context.SetMessageId(MessageId);
            context.SetRequestId(RequestId);
            context.SetConversationId(ConversationId);
            context.SetCorrelationId(CorrelationId);

            if (!string.IsNullOrEmpty(ExpirationTime))
            {
                context.SetExpirationTime(DateTime.Parse(ExpirationTime));
            }

            context.SetNetwork(Network);
            context.SetRetryCount(RetryCount);
            context.SetContentType(ContentType);

            return(context);
        }
        void SetHeaders(ScheduledMessageContext context)
        {
            if (string.IsNullOrEmpty(HeadersAsJson))
            {
                return;
            }

            var headers = JsonConvert.DeserializeObject <IEnumerable <KeyValuePair <string, string> > >(HeadersAsJson);

            context.SetHeaders(headers);
        }