public void RemovePath(string path) { foreach (string key in Bookmarks .Where(x => x.Key.Equals(path)) .Select(x => x.Key).ToList()) { Bookmarks.Remove(key); } if (BookmarkFolders.ContainsKey(path)) { BookmarkFolders.Remove(path); } foreach (string key in Bookmarks .Where(x => x.Key.StartsWith(path + '/', StringComparison.OrdinalIgnoreCase)) .Select(x => x.Key).ToList()) { Bookmarks.Remove(key); } foreach (string key in BookmarkFolders .Where(x => x.Key.StartsWith(path + '/', StringComparison.OrdinalIgnoreCase)) .Select(x => x.Key).ToList()) { BookmarkFolders.Remove(key); } }
public void CopyBookmarks(int level, string sourcePath, string targetPath) { if (sourcePath.Equals(targetPath, StringComparison.InvariantCulture)) { return; } if (targetPath.StartsWith(sourcePath, StringComparison.InvariantCulture)) { return; } foreach (KeyValuePair <string, BookmarkFolder> kvp in BookmarkFolders .Where(x => x.Key.StartsWith(sourcePath)).OrderBy(x => x.Key.Length).ToList()) { string[] sourcePathParts = kvp.Key.Split(new char[] { '/' }).Skip(level).ToArray(); string relativeSourcePath = string.Join("/", sourcePathParts); string combinedTargetPath = string.IsNullOrEmpty(targetPath) ? relativeSourcePath : (targetPath + "/" + relativeSourcePath); RegisterPath(combinedTargetPath, kvp.Value.Text); } foreach (string key in Bookmarks .Where(x => x.Key.StartsWith(sourcePath)) .Select(x => x.Key).ToList()) { string combinedTargetPath = CombineBookmarkPath(level, key, targetPath); CopyBookmark(key, combinedTargetPath); } }