Exemplo n.º 1
0
        /// <summary>Deserializes to an instance of XMLConfigCatalog.</summary>
        /// <param name="reader">TextReader instance.</param>
        /// <returns>XMLConfigCatalog result.</returns>
        public XMLConfigCatalog Deserialize(TextReader reader)
        {
            XMLConfigCatalog o = (XMLConfigCatalog)s.Deserialize(reader);

            reader.Close();
            return(o);
        }
Exemplo n.º 2
0
        private string StringSerialize(XMLConfigCatalog XMLConfigcatalog)
        {
            TextWriter w   = WriterSerialize(XMLConfigcatalog);
            string     xml = w.ToString();

            w.Close();
            return(xml);
        }
Exemplo n.º 3
0
        private TextWriter WriterSerialize(XMLConfigCatalog XMLConfigcatalog)
        {
            TextWriter w = new StringWriter();

            this.s = new XmlSerializer(this.type);
            s.Serialize(w, XMLConfigcatalog);
            w.Flush();
            return(w);
        }
Exemplo n.º 4
0
        /// <summary>Serializes to an XmlDocument.</summary>
        /// <param name="XMLConfigCatalog">XMLConfigCatalog to serialize.</param>
        /// <returns>XmlDocument instance.</returns>
        public XmlDocument Serialize(XMLConfigCatalog XMLConfigcatalog)
        {
            string      xml = StringSerialize(XMLConfigcatalog);
            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;
            doc.LoadXml(xml);
            doc = Clean(doc);
            return(doc);
        }
Exemplo n.º 5
0
        /// <summary>Writes config data to config file.</summary>
        /// <param name="file">Config file name.</param>
        /// <param name="config">Config object.</param>
        /// <returns></returns>
        public static bool WriteFile(string file, XMLConfigCatalog config)
        {
            bool ok = false;
            XMLConfigSerializer serializer = new XMLConfigSerializer();

            try
            {
                string xml = serializer.Serialize(config).OuterXml;
                using (StreamWriter writer = new StreamWriter(file, false))
                {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }
                ok = true;
            }
            catch { }
            return(ok);
        }