private static bool GetBool(EHNode node, bool defValue = false) { var doc = XElement.Load(Path); var profile = doc.Element(EHNode.Profile.Name); XElement?tarNode = profile !.Element(node.Name); if (tarNode == null) { profile.Add(new XElement(node.Name) { Value = defValue.ToString() }); doc.Save(Path); return(defValue); } else { return(bool.Parse(tarNode.Value)); } }
public static void SetValue(EHNode node, string value) { var doc = XDocument.Load(Path); var profile = doc.Element(EHNode.EHConfig.Name) !.Element(EHNode.Profile.Name); XElement?oldNode = profile !.Element(node.Name); if (oldNode != null) { oldNode.Value = value; } else { profile.Add(new XElement(node.Name) { Value = value }); } doc.Save(Path); }
private static string GetString(EHNode node, string defValue = "") { var doc = XElement.Load(Path); var profile = doc.Element(EHNode.Profile.Name); XElement?tarNode = profile !.Element(node.Name); if (tarNode == null) { profile.Add(new XElement(node.Name) { Value = defValue }); doc.Save(Path); return(defValue); } else { return(tarNode.Value); } }
private static long GetLong(EHNode node, long defValue = -1) { var doc = XElement.Load(Path); var profile = doc.Element(EHNode.Profile.Name); XElement?tarNode = profile !.Element(node.Name); if (tarNode == null) { profile.Add(new XElement(node.Name) { Value = defValue.ToString() }); doc.Save(Path); return(defValue); } else { return(long.Parse(tarNode.Value)); } }