public string GetValue(string name, string defaultValue) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath) == false) { return(defaultValue); } else { return(XMLUtil.GetNodeValue(root, valuePath)); } }
public string GetValue(string name) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath) == false) { valuePath = getValuePath("Util_" + name); if (XMLUtil.NodeExists(root, valuePath) == false) { return(string.Empty); } } return(XMLUtil.GetNodeValue(root, valuePath)); }
public void SetDefaultSettingValue(string name, string value) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(defaultroot, valuePath)) { XMLUtil.SetNodeValue(defaultroot, valuePath, value); } else { var cfg = XMLUtil.AddNode(defaultroot, "config"); XMLUtil.AddAttribute(cfg, "name", name); XMLUtil.AddAttribute(cfg, "value", value); } }
public void SetValue(string name, int value) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath)) { XMLUtil.SetNodeValue(root, valuePath, value.ToString()); } else { if (root != null) { var cfg = XMLUtil.AddNode(root, "config"); XMLUtil.AddAttribute(cfg, "name", name); XMLUtil.AddAttribute(cfg, "value", value.ToString()); } } }
public System.Drawing.Color GetValue(string name, System.Drawing.Color defaultColor) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath) == false) { return(defaultColor); } else { var val = XMLUtil.GetNodeValue(root, valuePath); int i; if (string.IsNullOrEmpty(val) || int.TryParse(val, out i) == false) { return(defaultColor); } else { return(System.Drawing.Color.FromArgb(i)); } } }
public int GetValueInt(string name, int defaultValue) { var i = defaultValue; var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath) == false) { valuePath = getValuePath("Util_" + name); if (XMLUtil.NodeExists(root, valuePath) == false) { return(defaultValue); } } var r = XMLUtil.GetNodeValue(root, valuePath); if (string.IsNullOrEmpty(r) || int.TryParse(r, out i) == false) { i = defaultValue; } return(i); }
public bool GetValueBool(string name, bool defaultValue) { var valuePath = getValuePath(name); if (XMLUtil.NodeExists(root, valuePath) == false) { valuePath = getValuePath("Util_" + name); if (XMLUtil.NodeExists(root, valuePath) == false) { return(defaultValue); } } var v = XMLUtil.GetNodeValue(root, valuePath); bool bret; if (string.IsNullOrEmpty(v) || bool.TryParse(v, out bret) == false) { return(defaultValue); } else { return(bret); } }
public bool HasSetting(string name) { return(XMLUtil.NodeExists(root, name)); }