public SolutionEventsListener(IVsSolution service, IVsSolutionBuildManager3 buildManager = null) {
     if (service == null) {
         throw new ArgumentNullException("service");
     }
     _solution = service;
     _buildManager = buildManager;
 }
示例#2
0
        public void Initialize(IServiceProvider serviceProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            ServiceProvider = serviceProvider;

            this.solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            Assumes.Present(this.solution);
            this.buildManager = ServiceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
            Assumes.Present(this.buildManager);

            FileWatcher.FileWatchedChanged += OnFolderActiveConfigurationChanged;
            FileWatcher.Verbosity           = false;

            //Start Listening for events
            this.solution.AdviseSolutionEvents(this, out this.cookie1);
            if (this.buildManager != null)
            {
                if (this.buildManager is IVsSolutionBuildManager2 bm2)
                {
                    bm2.AdviseUpdateSolutionEvents(this, out this.cookie2);
                }
                this.buildManager.AdviseUpdateSolutionEvents3(this, out this.cookie3);
            }

            CheckAlreadyOpenedContext();
        }
 public SolutionEventsListener(IVsSolution service, IVsSolutionBuildManager3 buildManager = null)
 {
     if (service == null)
     {
         throw new ArgumentNullException(nameof(service));
     }
     this._solution     = service;
     this._buildManager = buildManager;
 }
示例#4
0
 public SolutionEventsListener(IVsSolution service, IVsSolutionBuildManager3 buildManager = null)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     _solution     = service;
     _buildManager = buildManager;
 }
示例#5
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            ICPServiceProvider cpServProv = ICPServiceProvider.GetProvider();

            cpServProv.RegisterService <ICPTracerService>(new CPTracerService());

            IVsDebugger vsDebugService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;

            if (vsDebugService != null)
            {
                cpServProv.RegisterService <ICPDebugService>(new CPDebugService(vsDebugService));
            }

            ICPExtension extensionServ = new CPExtension();

            cpServProv.RegisterService <ICPExtension>(extensionServ);

            Globals.dte = (DTE)GetService(typeof(DTE));
            //factory = new ChartPntFactoryImpl();
            if (Globals.processor == null)
            {
                Globals.processor = CP.Utils.IClassFactory.GetInstance().CreateCPProc();
            }
            Globals.orchestrator = CP.Utils.IClassFactory.GetInstance().CreateCPOrchestrator();
            IVsSolution vsSolution = GetService(typeof(SVsSolution)) as IVsSolution;
            object      objLoadMgr = this; //the class that implements IVsSolutionManager

            vsSolution.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, objLoadMgr);
            solEvents = new VsSolutionEvents(this);
            uint solEvsCookie;

            vsSolution.AdviseSolutionEvents(solEvents, out solEvsCookie);
            buildManager3 = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
            cmdEvsHandler = new CmdEventsHandler(vsSolution);

            string vsixInstPath = extensionServ.GetVSIXInstallPath();
            string regSrvFName  = vsixInstPath + "\\cper.exe";

            if (File.Exists(regSrvFName))
            {
                string            message = "First time registration.\nAdministration privileges needed.";
                string            caption = "ChartPoints";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
                var p = new System.Diagnostics.Process();
                p.StartInfo.FileName    = regSrvFName;
                p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                p.StartInfo.Verb        = "runas";
                if (p.Start())
                {
                    p.WaitForExit();
                    File.Delete(regSrvFName);
                }
            }
        }
        public SolutionEventsListener(IServiceProvider serviceProvider) {
            if (serviceProvider == null) {
                throw new ArgumentNullException("serviceProvider");
            }

            _solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solution == null) {
                throw new InvalidOperationException("Cannot get solution service");
            }
            _buildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
        }
        private async SystemTask SubscribeAsync(Microsoft.VisualStudio.Shell.IAsyncServiceProvider serviceProvider)
        {
            // Don't use CPS thread helper because of RPS perf regression
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solutionBuildManager = await serviceProvider.GetServiceAsync <SVsSolutionBuildManager, IVsSolutionBuildManager3>();

            Assumes.Present(_solutionBuildManager);

            ((IVsSolutionBuildManager6)_solutionBuildManager).AdviseUpdateSolutionEventsEx(GuidList.guidNuGetSBMEvents, this, out _updateSolutionEventsCookieEx);
        }
示例#8
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);
        }
示例#9
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);
        }
        //private uint _cookie3 = VSConstants.VSCOOKIE_NIL;

        public BuildEventsBase(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            this._solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (this._solution == null)
            {
                throw new InvalidOperationException("Cannot get solution service");
            }
            this._buildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
        }
示例#11
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Handle commandline switch
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var cmdLine = await GetServiceAsync(typeof(SVsAppCommandLine)) as IVsAppCommandLine;

            ErrorHandler.ThrowOnFailure(cmdLine.GetOption(_cliSwitch, out int isPresent, out string optionValue));
            if (isPresent == 1)
            {
                System.Console.WriteLine(Vsix.Version);
            }

            _dte = await GetServiceAsync <DTE>();

            _solution = await GetServiceAsync <SVsSolution>() as IVsSolution;

            _solutionBuildManager = await GetServiceAsync <IVsSolutionBuildManager>() as IVsSolutionBuildManager3;

            var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte);

            await TaskScheduler.Default;

            var commandService = await GetServiceAsync <IMenuCommandService>();

            _vcProjectService = new VcProjectService();
            _settingsService  = new VisualStudioSettingsService(this);
            _errorListService = new ErrorListService();
            _conanService     = new ConanService(_settingsService, _errorListService, _vcProjectService);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _addConanDependsProject  = new AddConanDependsProject(commandService, _errorListService, _vcProjectService, _conanService);
            _addConanDependsSolution = new AddConanDependsSolution(commandService, _errorListService, _vcProjectService, _conanService);

            _conanOptions = new ConanOptions(commandService, _errorListService, ShowOptionPage);
            _conanAbout   = new ConanAbout(commandService, _errorListService);

            await TaskScheduler.Default;

            Logger.Initialize(serviceProvider, "Conan");

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            SubscribeToEvents();

            EnableMenus(_dte.Solution != null && _dte.Solution.IsOpen);

            await TaskScheduler.Default;
        }
示例#12
0
        public SolutionEventsListener(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            _solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solution == null)
            {
                throw new InvalidOperationException("Cannot get solution service");
            }
            _buildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
        }
        private async Task SubscribeAsync(Microsoft.VisualStudio.Shell.IAsyncServiceProvider serviceProvider)
        {
            // Don't use CPS thread helper because of RPS perf regression
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solutionBuildManager = await serviceProvider.GetServiceAsync <SVsSolutionBuildManager, IVsSolutionBuildManager3>();

            Assumes.Present(_solutionBuildManager);

            ((IVsSolutionBuildManager5)_solutionBuildManager).AdviseUpdateSolutionEvents4(this, out _updateSolutionEventsCookie4);

            ErrorHandler.ThrowOnFailure(
                ((IVsSolutionBuildManager2)_solutionBuildManager).AdviseUpdateSolutionEvents(
                    this, out _updateSolutionEventsCookie2));
        }
示例#14
0
        // A constructor utilized for running unit-tests
        public SolutionRestoreBuildHandler(
            ISettings settings,
            ISolutionRestoreWorker restoreWorker,
            IVsSolutionBuildManager3 buildManager)
        {
            Assumes.Present(settings);
            Assumes.Present(restoreWorker);
            Assumes.Present(buildManager);

            Settings = new Lazy <ISettings>(() => settings);
            SolutionRestoreWorker = new Lazy <ISolutionRestoreWorker>(() => restoreWorker);

            _solutionBuildManager = buildManager;

            _isMEFInitialized = true;
        }
        // A constructor utilized for running unit-tests
        public SolutionRestoreBuildHandler(
            INuGetLockService lockService,
            ISettings settings,
            ISolutionRestoreWorker restoreWorker,
            IVsSolutionBuildManager3 buildManager)
        {
            Assumes.Present(lockService);
            Assumes.Present(settings);
            Assumes.Present(restoreWorker);
            Assumes.Present(buildManager);

            LockService           = new Lazy <INuGetLockService>(() => lockService);
            Settings              = new Lazy <ISettings>(() => settings);
            SolutionRestoreWorker = new Lazy <ISolutionRestoreWorker>(() => restoreWorker);

            _solutionBuildManager = buildManager;
        }
示例#16
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            _dte = await GetServiceAsync <DTE>();

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solution = await GetServiceAsync <SVsSolution>() as IVsSolution;

            _solutionBuildManager = await GetServiceAsync <IVsSolutionBuildManager>() as IVsSolutionBuildManager3;

            var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte);

            await TaskScheduler.Default;

            var commandService = await GetServiceAsync <IMenuCommandService>();

            _vcProjectService = new VcProjectService();
            _settingsService  = new VisualStudioSettingsService(this);
            _errorListService = new ErrorListService();
            _conanService     = new ConanService(_settingsService, _errorListService, _vcProjectService);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solutionEventsHandler = new SolutionEventsHandler(this);
            _solution.AdviseSolutionEvents(_solutionEventsHandler, out var _solutionEventsCookie);

            _addConanDependsProject   = new AddConanDependsProject(commandService, _errorListService, _vcProjectService, _conanService);
            _addConanDependsSolution  = new AddConanDependsSolution(commandService, _errorListService, _vcProjectService, _conanService);
            _addConanDependsConanfile = new AddConanDependsConanfile(commandService, _errorListService, _vcProjectService, _conanService);

            _conanOptions = new ConanOptions(commandService, _errorListService, ShowOptionPage);

            await TaskScheduler.Default;

            Logger.Initialize(serviceProvider, "Conan");

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            SubscribeToEvents();

            EnableMenus(_dte.Solution != null && _dte.Solution.IsOpen);

            await TaskScheduler.Default;
        }
示例#17
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);
            }
        }