예제 #1
0
 public Message ToMessage(object obj, MessageProperties messageProperties)
 {
     try
     {
         if (obj is Message)
         {
             var embeddedMessage = obj as Message;
             if (embeddedMessage.Content is string)
             {
                 embeddedMessage.MessageProperties.ContentType = "text/string";
                 return(embeddedMessage);
             }
             else if (embeddedMessage.Content is JObject)
             {
                 var message = new Message(Encoding.UTF8.GetBytes(embeddedMessage.Content.ToString()), embeddedMessage.MessageProperties);
                 message.MessageProperties.ContentType           = _contentType;
                 message.MessageProperties.MessageBodyNativeType = messageProperties.MessageBodyNativeType;
                 return(message);
             }
         }
         else if (obj is JObject)
         {
             var message = new Message(Encoding.UTF8.GetBytes(obj.ToString()), messageProperties);
             message.MessageProperties.ContentType = _contentType;
             return(message);
         }
         else
         {
             messageProperties.MessageBodyNativeType = obj.GetType().AssemblyQualifiedName;
             var message = new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(obj)), messageProperties);
             message.MessageProperties.ContentType = _contentType;
             return(message);
         }
         throw new ApplicationException("Do not know how to convert message.");
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return(null);
     }
 }
예제 #2
0
 public Message(object content, MessageProperties messageProperties)
 {
     this.MessageProperties = messageProperties;
     this.Content           = content;
 }
예제 #3
0
        public Message ToMessage(object obj, MessageProperties messageProperties)
        {
            var message = new Message(obj, messageProperties);

            return(message);
        }
예제 #4
0
 public Message()
 {
     this.MessageProperties = new MessageProperties();
 }
예제 #5
0
 public Message ToMessage(object obj, MessageProperties messageProperties)
 {
     return(new Message(obj, messageProperties));
 }