예제 #1
0
        /// <summary>
        /// Write the current connection properties to an XML config file.
        /// TODO: Replace this with a better ConfigFile implementation that can write.
        /// </summary>
        /// <param name="file"></param>
        public void WriteToFile(string file)
        {
            XmlDocument doc  = new XmlDocument();
            string      name = "JabberClient";

            if (m_xmpp != null)
            {
                name = m_xmpp.GetType().Name;
            }
            XmlElement root = (XmlElement)doc.CreateElement(name);

            doc.AppendChild(root);

            WriteElem(root, this);

            foreach (DictionaryEntry ent in m_extra)
            {
                root.AppendChild(doc.CreateElement((string)ent.Key)).InnerText = ent.Value.ToString();
            }

            XmlTextWriter xw = new XmlTextWriter(file, System.Text.Encoding.UTF8);

            xw.Formatting = Formatting.Indented;
            doc.WriteContentTo(xw);
            xw.Close();
        }