private void ParseShortcuts(XmlReader _xmlReader) { m_ShortcutFolders.Clear(); while (_xmlReader.Read()) { if (_xmlReader.IsStartElement()) { if (_xmlReader.Name == "Shortcut") { ShortcutFolder sf = ShortcutFolder.FromXml(_xmlReader); if (sf != null) { m_ShortcutFolders.Add(sf); } } else { // forward compatibility : ignore new fields. } } else if (_xmlReader.Name == "Shortcuts") { break; } else { // Fermeture d'un tag interne. } } }
private void ParseShortcuts(XmlReader reader) { shortcutFolders.Clear(); bool empty = reader.IsEmptyElement; reader.ReadStartElement(); if (empty) { return; } while (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "Shortcut") { ShortcutFolder shortcut = new ShortcutFolder(reader); if (Directory.Exists(shortcut.Location)) { shortcutFolders.Add(shortcut); } } else { reader.ReadOuterXml(); } } reader.ReadEndElement(); shortcutFolders.Sort(); }
public void AddShortcut(ShortcutFolder shortcut) { bool known = shortcutFolders.Any(s => s.Location == shortcut.Location); if (!known) { shortcutFolders.Add(shortcut); shortcutFolders.Sort(); } }
public int CompareTo(object obj) { ShortcutFolder sf = obj as ShortcutFolder; if (sf != null) { String path1 = Path.GetFileName(this.location); String path2 = Path.GetFileName(sf.Location); return(path1.CompareTo(path2)); } else { throw new ArgumentException("Impossible comparison"); } }
public static ShortcutFolder FromXml(XmlReader _xmlReader) { // When we land in this method we MUST already be at the "Shortcut" node. string friendlyName = ""; string location = ""; while (_xmlReader.Read()) { if (_xmlReader.IsStartElement()) { if (_xmlReader.Name == "FriendlyName") { friendlyName = _xmlReader.ReadString(); } else if (_xmlReader.Name == "Location") { location = _xmlReader.ReadString(); } } else if (_xmlReader.Name == "Shortcut") { break; } else { // Fermeture d'un tag interne. } } ShortcutFolder sf = null; if (location.Length > 0) { sf = new ShortcutFolder(friendlyName, location); } return(sf); }
public void RemoveShortcut(ShortcutFolder shortcut) { shortcutFolders.RemoveAll(s => s.Location == shortcut.Location); }