Пример #1
0
        public SolutionEventsListener(IServiceProvider serviceProvider)
        {
            solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            solution?.AdviseSolutionEvents(this, out solutionEventsCookie);

            buildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
            buildManager?.AdviseUpdateSolutionEvents3(this, out updateSolutionEventsCookie);

            monitorSelection = serviceProvider.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
            monitorSelection?.AdviseSelectionEvents(this, out selectionEventsCoockie);
        }
Пример #2
0
 public void StartListeningForChanges()
 {
     ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _cookie1));
     if (_buildManager != null)
     {
         var bm2 = _buildManager as IVsSolutionBuildManager2;
         if (bm2 != null)
         {
             ErrorHandler.ThrowOnFailure(bm2.AdviseUpdateSolutionEvents(this, out _cookie2));
         }
         ErrorHandler.ThrowOnFailure(_buildManager.AdviseUpdateSolutionEvents3(this, out _cookie3));
     }
 }
Пример #3
0
        public Solution(EnvDTE.Solution nativeSolution)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            this.NativeSolution = nativeSolution;
            if (!IsReady)
            {
                return;
            }

            this.solutionEvents = nativeSolution.DTE.Events.SolutionEvents;
            this.FilePath       = nativeSolution.FullName;

            ReloadProjects();

            this.solutionEvents.ProjectAdded   += p => ReloadProjects();
            this.solutionEvents.ProjectRemoved += p => ReloadProjects();
            this.solutionEvents.ProjectRenamed += (p, n) => ReloadProjects();

            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
            if (sbm != null)
            {
                sbm.AdviseUpdateSolutionEvents3(this, out updateSolutionEventsCookie);
            }
        }