Exemplo n.º 1
0
        ///<summary>
        ///Create a full copy of the current properties
        ///</summary>
        public CustomConfigurationSection Copy()
        {
            CustomConfigurationSection copy = new CustomConfigurationSection();
            string xml = SerializeSection(this, "CustomConfigurationSection", ConfigurationSaveMode.Full);

            System.Xml.XmlReader rdr = new System.Xml.XmlTextReader(new System.IO.StringReader(xml));
            copy.DeserializeSection(rdr);
            return(copy);
        }
Exemplo n.º 2
0
        ///<summary>
        ///Save the current property values to the config file
        ///</summary>
        public void Save(string path)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ParserConfigurationPath(path));
            CustomConfigurationSection section = (CustomConfigurationSection)config.Sections["CustomConfigurationSection"];

            // copy data
            section.EngineSetting       = this.EngineSetting;
            section.EditorEngineSetting = this.EditorEngineSetting;

            //Try with "Modified" to see the difference
            config.Save(ConfigurationSaveMode.Full);
        }
Exemplo n.º 3
0
 ///<summary>
 /// Get this configuration set from a specific config file
 ///</summary>
 public static CustomConfigurationSection Open(string path)
 {
     if ((object)instance == null)
     {
         Configuration config = ConfigurationManager.OpenExeConfiguration(ParserConfigurationPath(path));
         if (config.Sections["CustomConfigurationSection"] == null)
         {
             instance = new CustomConfigurationSection();
             config.Sections.Add("CustomConfigurationSection", instance);
             config.Save(ConfigurationSaveMode.Modified);
         }
         else
         {
             instance = (CustomConfigurationSection)config.Sections["CustomConfigurationSection"];
         }
     }
     return(instance);
 }