Пример #1
0
 ///<summary>Create a full copy of the current properties</summary>
 public ConfigData Copy()
 {
     ConfigData copy = new ConfigData();
     string xml = SerializeSection(this, "ConfigData", ConfigurationSaveMode.Full);
     System.Xml.XmlReader rdr = new System.Xml.XmlTextReader(new System.IO.StringReader(xml));
     copy.DeserializeSection(rdr);
     return copy;
 }
Пример #2
0
 ///<summary>Get this configuration set from a specific config file</summary>
 public static ConfigData Open(string path)
 {
     if (instance == null)
     {
         if (path.EndsWith(".config", StringComparison.InvariantCultureIgnoreCase))
             spath = path.Remove(path.Length - 7);
         else
             spath = path;
         Configuration config = ConfigurationManager.OpenExeConfiguration(spath);
         if (config.Sections["ConfigData"] == null)
         {
             instance = new ConfigData();
             config.Sections.Add("ConfigData", instance);
             config.Save(ConfigurationSaveMode.Modified);
         }
         else
             instance = (ConfigData)config.Sections["ConfigData"];
     }
     return instance;
 }