title: C# Rabbitmq serialize message and desiralize original type
body: <p>I am using Rabbitmq client to produce and consume messages. My messages is like this.</p>
  
  <pre><code>public interface IMessage{}
  
  public class PlaceOrder: IMessage{ 
    public string id{ get; set; }
  }    
  </code></pre>
  
  <p>I have two c# console applicaiton projects. One of them <strong>Producer</strong> and other is <strong>Consumer</strong>.</p>
  
  <h2>Producer console applicaiton</h2>
  
  <pre><code>public class Producer{
      public void Save(IMessage message){
          ....
          var serializedObject = JsonConvert.SerializeObject(message);
          ....
          // append queue serializedObject 
      }
  }
  </code></pre>
  
  <h2>Consumer console applicaiton</h2>
  
  <pre><code>public class Consumer{
      public void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body){
          ....
          var message = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(body));
          ....
  
      }
  }
  </code></pre>
  
  <p>Here <code>message</code> type is Object. And consumer console applicaiton does not knows <strong>PlaceOrder</strong> type. It only knows IMessage interface type. How can I cast or convert original type.</p>