Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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));
            }
        }