XElement GetTab(TabModel tab) { return ((from sectionXml in _database.Element("Tabs").Elements("Tab") where sectionXml.Element("Title").Value == tab.Title || sectionXml.Element("Title").Value == tab.OldTitle select sectionXml).Single()); }
void Update(TabModel updateThis) { Log.DebugFormat("Update {0}", updateThis.OldTitle); var tab = GetTab(updateThis); tab.ReplaceWith(TabToXml(updateThis)); }
void Remove(TabModel removeThis) { Log.DebugFormat("Remove {0}", removeThis.Title); var section = GetTab(removeThis); section.Remove(); }
XElement TabToXml(TabModel section) { XElement xml = new XElement("Tab", new XElement("Title", section.Title), new XElement("IsExpanded", section.IsExpanded), new XElement("TabOrder", section.TabOrder)); return(xml); }
public IEnumerable <ApplicationModel> LoadApplications(TabModel forThis) { if (forThis == null) { throw new ArgumentNullException("forThis"); } return(from elem in _database.Element("Applications").Elements("Application") where elem.GetValue("Tab") == forThis.Title select ApplicationFromXml(elem)); }
void Move(TabModel moveThis, TabModel moveToThis) { Log.DebugFormat("Move {0} to {1}", moveThis.Title, moveToThis.Title); var moveThisXml = GetTab(moveThis); var moveToThisXml = GetTab(moveToThis); // Move xml from current position to just above the other tab. moveThisXml.Remove(); moveToThisXml.AddBeforeSelf(moveThisXml); }
public IEnumerable <TabModel> LoadTabs() { var xml = from elem in _database.Element("Tabs").Elements("Tab") select elem; foreach (XElement xmlSection in xml) { TabModel tabModel = TabFromXml(xmlSection); foreach (var appModel in LoadApplications(tabModel)) { tabModel.Applications.Add(appModel); } yield return(tabModel); } }
void Add(TabModel addThis) { Log.DebugFormat("Add {0}", addThis.Title); _database.Element("Tabs").Add(TabToXml(addThis)); }