Пример #1
0
        private XmlElement CreateRecordElement(SaveOption rec)
        {
            XmlElement record = _document.CreateElement("Save");

            record.SetAttribute("Title", rec.Title);
            record.SetAttribute("Value", rec.Value);
            return(record);
        }
Пример #2
0
 private XElement FindElement(IEnumerable <XElement> records, SaveOption rec)
 {
     foreach (XElement element in records)
     {
         SaveOption founded = ParseSave(element);
         if (rec.Title == founded.Title)
         {
             return(element);
         }
     }
     return(null);
 }
Пример #3
0
        public void EditXml(SaveOption oldOpt, SaveOption newOpt)
        {
            XElement root = XElement.Load(_path);
            XElement el   = FindElement(root.Elements(), oldOpt);

            if (el == null)
            {
                return;
            }
            XElement newEl = XElement.Parse(CreateRecordElement(newOpt).OuterXml);

            el.ReplaceWith(
                newEl
                );
            root.Save(_path);
        }