Serialize() public static method

Serialize the object to XML format. The XML encoding will be UTF-8. A Byte Order Mark (BOM) will NOT be placed at the beginning of the string.
public static Serialize ( object obj ) : string
obj object
return string
Beispiel #1
0
 /// <summary>
 /// Serialize the object as XML into the Text body of the message.
 /// Set the NMSType to the full name of the object type.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="obj"></param>
 /// <returns></returns>
 internal static ITextMessage SerializeObjToMessage(ITextMessage message, object obj)
 {
     // Embed the type into the message
     message.NMSType = obj.GetType().FullName;
     message.Text    = XmlUtil.Serialize(obj);
     return(message);
 }
Beispiel #2
0
        /// <summary>
        /// Convert an object into a text message.  The object must be serializable to XML.
        /// </summary>
        public static ITextMessage ToXmlMessage(ISession session, object obj)
        {
            ITextMessage message = session.CreateTextMessage(XmlUtil.Serialize(obj));

            // Embed the type into the message
            message.NMSType = obj.GetType().FullName;
            return(message);
        }
Beispiel #3
0
        /// <summary>
        /// Convert an object into a text message.  The object must be serializable to XML.
        /// </summary>
        public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj)
        {
            ITextMessage message = producer.CreateTextMessage(XmlUtil.Serialize(obj));

            // Embed the type into the message
            message.NMSType = obj.GetType().FullName;
            return(message);
        }