示例#1
0
 private void SettingsEditorForm_Load(object sender, EventArgs e)
 {
     editedParamName = string.Empty;
     ClearGUI();
     if (Settings == null)
     {
         Settings = new Settings();
     }
     FillSettingsToGUI(Settings);
 }
示例#2
0
 //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();
 }
示例#3
0
 private static XElement SerializeSettings(Settings settings)
 {
     XElement xSettings = new XElement("settings");
     if (settings != null)
     {
         SerializeSectionBase(settings, xSettings);
     }
     return xSettings;
 }
示例#4
0
 public ServiceSettings()
 {
     Settings = new Settings();
     InstallerSettings = new InstallerSettings();
     TraceLoggerSettings = new TraceLoggerSettings();
 }
示例#5
0
        // 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;
        }