Ejemplo n.º 1
0
        public void WriteSettingsFile()
        {
            if (!xDoc.Descendants("someNodeName").Any())
            {
                return;
            }

            foreach (var desc in xDoc.Descendants("someNodeName"))
            {
                desc.SetValue(TheAnswerToLifeUniverseAndEverything);
            }

            xDoc.Save(SettingsFile);
        }
Ejemplo n.º 2
0
        public decimal?GetPrice(string bookId)
        {
            var book = xDoc.Descendants("book")
                       .Where(x => x.Attribute("id").Value == bookId)
                       .SingleOrDefault();

            return(decimal.TryParse(book?.Element("price")?.Value, out decimal price) ? price : (decimal?)null);
        }