Beispiel #1
0
        /// <summary>
        /// Saves the configuration to the specified writer.
        /// </summary>
        protected override void Save(TextWriter writer)
        {
            XmlDocument    xmlDoc  = new();
            XmlDeclaration xmlDecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDoc.AppendChild(xmlDecl);

            XmlElement rootElem = xmlDoc.CreateElement("ScadaWebConfig");

            xmlDoc.AppendChild(rootElem);

            GeneralOptions.SaveToXml(rootElem.AppendElem("GeneralOptions"));
            ConnectionOptions.SaveToXml(rootElem.AppendElem("ConnectionOptions"));
            LoginOptions.SaveToXml(rootElem.AppendElem("LoginOptions"));
            DisplayOptions.SaveToXml(rootElem.AppendElem("DisplayOptions"));

            XmlElement pluginsElem = rootElem.AppendElem("Plugins");

            foreach (string pluginCode in PluginCodes)
            {
                pluginsElem.AppendElem("Plugin").SetAttribute("code", pluginCode);
            }

            PluginAssignment.SaveToXml(rootElem.AppendElem("PluginAssignment"));

            XmlElement customOptionsElem = rootElem.AppendElem("CustomOptions");

            foreach (KeyValuePair <string, OptionList> pair in CustomOptions)
            {
                XmlElement optionGroupElem = customOptionsElem.AppendElem("OptionGroup");
                optionGroupElem.SetAttribute("name", pair.Key);
                pair.Value.SaveToXml(optionGroupElem);
            }

            xmlDoc.Save(writer);
        }