private void SettingsEditorForm_Load(object sender, EventArgs e) { editedParamName = string.Empty; ClearGUI(); if (Settings == null) { Settings = new Settings(); } FillSettingsToGUI(Settings); }
//private Settings FillSettingsFromGUI() //{ // return new Settings(); //} private void FillSettingsToGUI(Settings settings) { sectionsTreeView.BeginUpdate(); TreeNode root = sectionsTreeView.Nodes.Add("(root settings)"); root.Tag = settings; if (settings != null) { FillSection(root, settings); } sectionsTreeView.SelectedNode = root; sectionsTreeView.ExpandAll(); sectionsTreeView.EndUpdate(); }
private static XElement SerializeSettings(Settings settings) { XElement xSettings = new XElement("settings"); if (settings != null) { SerializeSectionBase(settings, xSettings); } return xSettings; }
public ServiceSettings() { Settings = new Settings(); InstallerSettings = new InstallerSettings(); TraceLoggerSettings = new TraceLoggerSettings(); }
// TODO: refactor common code similarly to SerializeSectionBase() private static Settings DeserializeSettings(XElement xSettings) { Settings settings = new Settings(); if (xSettings == null) { return settings; } foreach (var node in xSettings.XPathSelectElements("child::*")) { XElement xElement = (XElement)node; if (xElement.Name == "section") { Sections section = new Sections(); settings[xElement.Attribute(XName.Get("name")).Value] = section; DeserializeSection(section, xElement); } else { settings.Parameters[xElement.Attribute(XName.Get("name")).Value] = xElement.Value; } } return settings; }