Beispiel #1
0
        /// <summary>
        /// This method generates object from xml string data
        /// </summary>
        /// <param name="xmlserializer">XML Serializer object</param>
        /// <param name="objectToDeSerialize">Object to be deserialized</param>
        /// <returns>string containing XML data</returns>
        public static Object ObjectfromXMLString(XmlSerializer xmlserializer, string stringXMLToDeSerialize)
        {
            var stringWriter = new EnzeoCodeStringWriter();

            try
            {
                using (TextReader reader = new StringReader(stringXMLToDeSerialize))
                {
                    return(xmlserializer.Deserialize(reader));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method generates xml data of object
        /// </summary>
        /// <param name="xmlserializer">XML Serializer object</param>
        /// <param name="objectToSerialize">Object to be serialized</param>
        /// <returns>string containing XML data</returns>
        public static string XMLfromObject(XmlSerializer xmlserializer, Object objectToSerialize)
        {
            var stringWriter = new EnzeoCodeStringWriter();

            try
            {
                using (var writer = System.Xml.XmlWriter.Create(stringWriter))
                {
                    xmlserializer.Serialize(writer, objectToSerialize);
                    return(stringWriter.ToString());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }