Deserialize() public static method

public static Deserialize ( Type objType, string text ) : object
objType System.Type
text string
return object
Beispiel #1
0
        /// <summary>
        /// Deserialize the object from the text message.  The object must be serializable from XML.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        internal static object DeserializeObjFromMessage(IMessage message)
        {
            ITextMessage textMessage = message as ITextMessage;

            if (null == textMessage)
            {
                return(null);
            }

            if (null == textMessage.NMSType || textMessage.NMSType.Length < 1)
            {
                Tracer.ErrorFormat("NMSType not set on message.  Could not deserializing XML object.");
                return(null);
            }

            Type objType = GetRuntimeType(textMessage.NMSType);

            if (null == objType)
            {
                Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
                return(null);
            }

            return(XmlUtil.Deserialize(objType, textMessage.Text));
        }
Beispiel #2
0
        /// <summary>
        /// Convert a text message into an object.  The object must be serializable from XML.
        /// </summary>
        public static object FromXmlMessage(IMessage message)
        {
            ITextMessage textMessage = message as ITextMessage;

            if (null == textMessage)
            {
                return(null);
            }

            Type objType = GetRuntimeType(textMessage.NMSType);

            if (null == objType)
            {
                Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
                return(null);
            }

            return(XmlUtil.Deserialize(objType, textMessage.Text));
        }