コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionManager"/> class.
 /// </summary>
 public SolutionManagerService(IServiceProvider serviceProvider)
 {
     Guard.ArgumentNotNull(serviceProvider, "ServiceProvider");
     _serviceProvider = serviceProvider;
     _solutionListener = new SolutionListener(this, serviceProvider);
     _solutionListener.ProjectChanged += new EventHandler<ProjectChangedEventArg>(OnProjectChanged);
     _solutionListener.SolutionEvents += new SolutionEventsHandler(OnSolutionEvents);
     IVsSolutionBuildManager vsSolutionManager = serviceProvider.GetService(typeof(IVsSolutionBuildManager)) as IVsSolutionBuildManager;
     if (vsSolutionManager != null)
         vsSolutionManager.AdviseUpdateSolutionEvents(this, out _sdmCookie);
 }
コード例 #2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_solutionListener != null)
     {
         _solutionListener.ProjectChanged -= new EventHandler<ProjectChangedEventArg>(OnProjectChanged);
         _solutionListener.SolutionEvents -= new SolutionEventsHandler(OnSolutionEvents);
         _solutionListener.Dispose();
         _solutionListener = null;
     }
     //if (_buildListener != null)
     //{
     //    _buildListener.BuildCompleted -= new EventHandler<BuildCompleteEventArgs>(OnBuildCompleted);
     //    _buildListener.Dispose();
     //    _buildListener = null;
     //}
     if (_sdmCookie != 0)
     {
         IVsSolutionBuildManager vsSolutionManager = _serviceProvider.GetService(typeof(IVsSolutionBuildManager)) as IVsSolutionBuildManager;
         if (vsSolutionManager != null)
             vsSolutionManager.UnadviseUpdateSolutionEvents(_sdmCookie);
     }
 }