public void LoadBookmarksFromDatFile()
        {
            if (!StorageOptions.SaveBookmarksToOwnFile)
            {
                return;
            }

            if (!File.Exists(DataFilePath))
            {
                return;
            }

            SerializableBookmarksInfo info;

            try
            {
                using (var stream = File.OpenRead(DataFilePath))
                    info = SerializableBookmarksInfo.DeserializeFrom(stream);
            }
            catch
            {
                Helpers.ShowErrorMessage("Sorry, I couldn't parse the .SuperBookmarks.dat file, perhaps it is corrupted?", showHeader: false);
                return;
            }

            this.BookmarksManager.DeleteAllBookmarksIn(BookmarkActionTarget.Solution);

            try
            {
                this.BookmarksManager.RecreateBookmarksFromSerializedInfo(info);
            }
            catch
            {
                Helpers.ShowErrorMessage("Sorry, I couldn't get bookmarks data the .SuperBookmarks.dat file, perhaps it is corrupted?", showHeader: false);
                return;
            }

            Helpers.WriteToStatusBar($"Restored {Helpers.Quantifier(info.TotalBookmarksCount, "bookmark")} for {Helpers.Quantifier(info.TotalFilesCount, "file")} from .SuperBookmarks.dat file");
        }
Ejemplo n.º 2
0
        private int _ReadUserOptions(IStream pOptionsStream, string pszKey)
        {
            if (pszKey != persistenceKey)
            {
                throw new InvalidOperationException("SuperBookmarks: ReadUserOptions was called for unknown key " + pszKey);
            }

            var stream = new DataStreamFromComStream(pOptionsStream);
            SerializableBookmarksInfo info;

            try
            {
                info = SerializableBookmarksInfo.DeserializeFrom(stream);
            }
            catch
            {
                Helpers.ShowErrorMessage("Sorry, I couldn't parse the bookmarks information from the .suo file", showHeader: false);
                return(VSConstants.S_OK);
            }
            this.BookmarksManager.RecreateBookmarksFromSerializedInfo(info);
            Helpers.WriteToStatusBar($"Restored {Helpers.Quantifier(info.TotalBookmarksCount, "bookmark")} for {Helpers.Quantifier(info.TotalFilesCount, "file")} from .suo file");

            return(VSConstants.S_OK);
        }