public Solution(ITracer tracer, IVsServiceProvider serviceProvider, 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);
            _solutionContexts      = SolutionConfigurations.ObservableSelectMany(cfg => cfg.Contexts);
            _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();
        }
Пример #2
0
        public Solution(ITracer tracer, IVsServiceProvider serviceProvider)
        {
            Contract.Requires(tracer != null);
            Contract.Requires(serviceProvider != null);

            _deferredUpdateThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, Update);

            _tracer          = tracer;
            _serviceProvider = serviceProvider;

            _specificProjectConfigurations = Projects.ObservableSelectMany(prj => prj.SpecificProjectConfigurations);
            _solutionContexts             = SolutionConfigurations.ObservableSelectMany(cfg => cfg.Contexts);
            _defaultProjectConfigurations = Projects.ObservableSelect(prj => prj.DefaultProjectConfiguration);
            _projectConfigurations        = new ObservableCompositeCollection <ProjectConfiguration>(_defaultProjectConfigurations, _specificProjectConfigurations);

            _solutionEvents = Dte?.Events?.SolutionEvents;
            if (_solutionEvents != null)
            {
                _solutionEvents.Opened         += Solution_Changed;
                _solutionEvents.AfterClosing   += Solution_Changed;
                _solutionEvents.ProjectAdded   += _ => Solution_Changed();
                _solutionEvents.ProjectRemoved += _ => Solution_Changed();
                _solutionEvents.ProjectRenamed += (_, __) => Solution_Changed();
            }

            Update();
        }