public Solution([NotNull] ITracer tracer, [NotNull] IVsServiceProvider serviceProvider, [NotNull] PerformanceTracer performanceTracer) { Tracer = tracer; _serviceProvider = serviceProvider; _performanceTracer = performanceTracer; SpecificProjectConfigurations = Projects.ObservableSelectMany(prj => prj.SpecificProjectConfigurations); ProjectConfigurations = Projects.ObservableSelectMany(prj => prj.ProjectConfigurations); var solutionEvents = Dte?.Events?.SolutionEvents; if (solutionEvents != null) { solutionEvents.Opened += () => OnSolutionChanged("Solution opened"); solutionEvents.AfterClosing += () => OnSolutionChanged("Solution after closing"); solutionEvents.ProjectAdded += _ => OnSolutionChanged("Project added"); solutionEvents.ProjectRemoved += _ => OnSolutionChanged("Project removed"); solutionEvents.ProjectRenamed += (_, __) => OnSolutionChanged("Project renamed"); } _solutionEvents = solutionEvents; Update(0); CommandManager.RequerySuggested += (_, __) => Projects.ForEach(proj => proj?.InvalidateState()); }
public Solution([NotNull] ITracer tracer, [NotNull] IVsServiceProvider serviceProvider, [NotNull] PerformanceTracer performanceTracer) { Contract.Requires(tracer != null); Contract.Requires(serviceProvider != null); Contract.Requires(performanceTracer != null); _deferredUpdateThrottle = new DispatcherThrottle(DispatcherPriority.ApplicationIdle, Update); _tracer = tracer; _serviceProvider = serviceProvider; _performanceTracer = performanceTracer; _specificProjectConfigurations = _projects.ObservableSelectMany(prj => prj.SpecificProjectConfigurations); _projectConfigurations = _projects.ObservableSelectMany(prj => prj.ProjectConfigurations); _solutionEvents = Dte?.Events?.SolutionEvents; if (_solutionEvents != null) { _solutionEvents.Opened += () => Solution_Changed("Solution opened"); _solutionEvents.AfterClosing += () => Solution_Changed("Solution after closing"); _solutionEvents.ProjectAdded += _ => Solution_Changed("Project added"); _solutionEvents.ProjectRemoved += _ => Solution_Changed("Project removed"); _solutionEvents.ProjectRenamed += (_, __) => Solution_Changed("Project renamed"); } Update(); }