private void OnSolutionEventsOnOpened() { _documentEvents.DocumentClosing += DocumentEventsOnDocumentClosing; SolutionState = SolutionStates.Opened; string slnPath = _dte.Solution.FullName; //can be empty if it is a new solution?? LoggerContext.Current.Logger.Info($"{nameof(DocumentEventsTracker)}.{nameof(OnSolutionEventsOnOpened)}() method executing. Opened solution Full path: '{slnPath}'"); if (string.IsNullOrWhiteSpace(slnPath)) { slnPath = _dte.Solution.Properties.Item("Path")?.Value?.ToString(); //https://github.com/3F/vsCommandEvent/blob/master/vsCommandEvent/Environment.cs LoggerContext.Current.Logger.Warning($"{nameof(DocumentEventsTracker)}.{nameof(OnSolutionEventsOnOpened)}() method executing. _dte.Solution.FullName was EMPTY or NULL. Getting Solution.Properties Full path: '{slnPath}'"); } var solutionDir = Path.GetDirectoryName(slnPath); var solutionName = Path.GetFileName(slnPath).Replace(".sln", string.Empty); _currentSolution = new SolutionInfo(solutionDir, solutionName); //Create history repo var historyRepository = _historyRepositoryFactory.CreateHistoryRepository(_currentSolution); //Load history and init state var history = historyRepository?.GetHistory(); _documentHistoryManager.Initialize(history); }
private void Initialize() { SolutionState = SolutionStates.None; _solutionEvents.Opened += OnSolutionEventsOnOpened; _solutionEvents.BeforeClosing += OnSolutionEventsOnBeforeClosing; _solutionEvents.AfterClosing += OnSolutionEventsOnAfterClosing; if (_dte.Solution.IsOpen) //VS2019 pushing for Async loading it is possible to have a loaded solution at this point... { OnSolutionEventsOnOpened(); } }
private void OnSolutionEventsOnAfterClosing() { _documentEvents.DocumentClosing -= DocumentEventsOnDocumentClosing; //Save state var historyRepository = _historyRepositoryFactory.CreateHistoryRepository(_currentSolution); if (!historyRepository.SaveHistory(_documentHistoryManager.GetAll())) { _messageBox.ShowError("Visual Studio Document Reopen", "Failed to save Closed Document History!"); } SolutionState = SolutionStates.None; _currentSolution = null; _documentHistoryManager.Clear(); }
private void OnSolutionEventsOnOpened() { _documentEvents.DocumentClosing += DocumentEventsOnDocumentClosing; SolutionState = SolutionStates.Opened; var solutionDir = Path.GetDirectoryName(_dte.Solution.FullName); var solutionName = Path.GetFileName(_dte.Solution.FullName).Replace(".sln", string.Empty); _currentSolution = new SolutionInfo(solutionDir, solutionName); //Create history repo var historyRepository = _historyRepositoryFactory.CreateHistoryRepository(_currentSolution); //Load history and init state var history = historyRepository?.GetHistory(); _documentHistoryManager.Initialize(history); }
private void OnSolutionEventsOnBeforeClosing() { //TODO: try to validate if it was closed or canceled... SolutionState = SolutionStates.StartedToClose; }