/// <summary> /// Deserializes the data for a bookmarks folder from <paramref name="reader"/>. /// </summary> /// <param name="reader">XML source that we're deserializing this folder from.</param> public void ReadXml(XmlReader reader) { // Move to the child nodes reader.MoveToContent(); reader.Read(); while (reader.MoveToContent() == XmlNodeType.Element) { switch (reader.LocalName) { case "Name": Name = reader.ReadElementContentAsString(); break; case "Username": Username = reader.ReadElementContentAsString(); break; case "Password": EncryptedPassword = reader.ReadElementContentAsString(); break; case "ChildFolders": if (!reader.IsEmptyElement) { reader.Read(); // Call this method recursively to read each child folder while (reader.MoveToContent() == XmlNodeType.Element) { BookmarksFolder childFolder = new BookmarksFolder(); childFolder.ReadXml(reader); ChildFolders.Add(childFolder); } } reader.Read(); break; case "Bookmarks": if (!reader.IsEmptyElement) { reader.Read(); while (reader.MoveToContent() == XmlNodeType.Element) { Bookmarks.Add(ConnectionFactory.Deserialize(reader)); } } reader.Read(); break; } } reader.Read(); }
/// <summary> /// When pasting a child folder into this folder, if a child folder by the same name already exists, we merge the contents of /// <paramref name="childFolder"/> with that folder. Bookmarks in <paramref name="childFolder"/> are copied to the destination folder; we don't /// overwrite any bookmarks that have the same name. This merge process is then carried out recursively on all descendant folders of /// <paramref name="childFolder"/>. /// </summary> /// <param name="childFolder">Child folder that we are copying or merging into this folder.</param> public void MergeFolder(BookmarksFolder childFolder) { if (ChildFolders.Any(f => f.Name == childFolder.Name)) { BookmarksFolder mergeTarget = ChildFolders.First(f => f.Name == childFolder.Name); foreach (IConnection bookmark in childFolder.Bookmarks) { mergeTarget.Bookmarks.Add(bookmark); } foreach (BookmarksFolder folder in childFolder.ChildFolders) { mergeTarget.MergeFolder(folder); } } else { ChildFolders.Add(childFolder); } }
public void AddChildFolder(AddedShareFolder childFolder) { ChildFolders.Add(childFolder); RaisePropertyChanged("ChildFolders"); }