Beispiel #1
0
		///<summary>
		///Create a full copy of the current properties
		///</summary>
		public MySection Copy()
		{
			MySection copy = new MySection();
			string xml = SerializeSection(this, "MySection", ConfigurationSaveMode.Full);
			System.Xml.XmlReader rdr = new System.Xml.XmlTextReader(new System.IO.StringReader(xml));
			copy.DeserializeSection(rdr);
			return copy;
		}
Beispiel #2
0
		private void btnOpenSection_Click(object sender, EventArgs e)
		{
			settings = MySection.Open();
			this.btnSaveSection.Enabled = true;
			this.btnOpenSection.Enabled = false;
			this.txtDevAShape.Text = settings.UnitShapeConfig.DevA.Shape;
			this.txtDevBShape.Text = settings.UnitShapeConfig.DevB.Shape;
			this.chkEnableShapes.Checked = settings.UnitShapeConfig.Enable;
		}
Beispiel #3
0
		///<summary>
		/// Get this configuration set from a specific config file
		///</summary>
		public static MySection Open(string path)
		{
			if ((object)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["MySection"] == null)
				{
					instance = new MySection();
					config.Sections.Add("MySection", instance);
					config.Save(ConfigurationSaveMode.Modified);
				}
				else
					instance = (MySection)config.Sections["MySection"];
			}
			return instance;
		}