void ToggleCreateBreakpoint(ToggleCreateBreakpointInfoResult info) { using (info) { switch (info.kind) { case ToggleCreateBreakpointKind.Add: dbgCodeBreakpointsService.Value.Add(info.locations.Select(a => new DbgCodeBreakpointInfo(a.Clone(), new DbgCodeBreakpointSettings() { IsEnabled = true })).ToArray()); break; case ToggleCreateBreakpointKind.Delete: dbgCodeBreakpointsService.Value.Remove(info.breakpoints); break; case ToggleCreateBreakpointKind.Enable: dbgCodeBreakpointsService.Value.Modify(info.breakpoints.Select(a => { var newSettings = a.Settings; newSettings.IsEnabled = true; return(new DbgCodeBreakpointAndSettings(a, newSettings)); }).ToArray()); break; case ToggleCreateBreakpointKind.None: default: return; } } }
void ToggleCreateBookmark(ToggleCreateBreakpointInfoResult info) { try { switch (info.kind) { case ToggleCreateBookmarkKind.Add: var bookmark = bookmarksService.Value.Add(new Contracts.Bookmarks.BookmarkInfo(info.TakeOwnershipOfLocation() !, new BookmarkSettings() { IsEnabled = true })); if (bookmark is not null) { bookmarkNavigator.Value.SetActiveBookmarkNoCheck(bookmark); } break; case ToggleCreateBookmarkKind.Delete: bookmarksService.Value.Remove(info.bookmarks); break; case ToggleCreateBookmarkKind.None: default: return; } } finally { // Don't use a using statement since the compiler will make a copy of it and this // copy will always dispose the bookmark location. info.Dispose(); } }