public Message ToMessage(object objectToConvert, ISession session)
 {
     if (objectToConvert == null)
     {
         throw new MessageConversionException("Can't convert null object");
     }
     try
     {
         if (objectToConvert.GetType().Equals(typeof(string)) ||
             typeof(IDictionary).IsAssignableFrom(objectToConvert.GetType()) ||
             objectToConvert.GetType().Equals(typeof(Byte[])))
         {
             return(defaultMessageConverter.ToMessage(objectToConvert, session));
         }
         else
         {
             string  xmlString = GetXmlString(objectToConvert);
             Message msg       = session.CreateTextMessage(xmlString);
             msg.SetStringProperty(typeMapper.TypeIdFieldName, typeMapper.FromType(objectToConvert.GetType()));
             return(msg);
         }
     } catch (Exception e)
     {
         throw new MessageConversionException("Can't convert object of type " + objectToConvert.GetType(), e);
     }
 }