/// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="serviceProvider">Owner package, not null.</param>
        public static async Task InitializeAsync(Microsoft.VisualStudio.Shell.IAsyncServiceProvider serviceProvider)
        {
            Assumes.Present(serviceProvider);

            _instance = new SolutionRestoreCommand();

            await _instance.SubscribeAsync(serviceProvider);
        }
        protected override async Task InitializeAsync(
            CancellationToken cancellationToken,
            IProgress <ServiceProgressData> progress)
        {
            _handler = await SolutionRestoreBuildHandler.InitializeAsync(this);

            await SolutionRestoreCommand.InitializeAsync(this);

            await base.InitializeAsync(cancellationToken, progress);
        }
Пример #3
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="serviceProvider">Owner package, not null.</param>
        public static async Task InitializeAsync(Microsoft.VisualStudio.Shell.IAsyncServiceProvider serviceProvider)
        {
            Assumes.Present(serviceProvider);

            _instance = new SolutionRestoreCommand();

            var componentModel = await serviceProvider.GetComponentModelAsync();

            componentModel.DefaultCompositionService.SatisfyImportsOnce(_instance);

            await _instance.SubscribeAsync(serviceProvider);
        }
Пример #4
0
        protected override async Task InitializeAsync(
            CancellationToken cancellationToken,
            IProgress <ServiceProgressData> progress)
        {
            _handler = await SolutionRestoreBuildHandler.InitializeAsync(this);

            await SolutionRestoreCommand.InitializeAsync(this);

            // Set up brokered services - Do not reference NuGet.VisualStudio.Internals.Contract explicitly to avoid an unnecessary assembly load
            IBrokeredServiceContainer brokeredServiceContainer = await this.GetServiceAsync <SVsBrokeredServiceContainer, IBrokeredServiceContainer>();

            brokeredServiceContainer.Proffer(BrokeredServicesUtility.NuGetSolutionService, factory: BrokeredServicesUtility.GetNuGetSolutionServicesFactory());

            await base.InitializeAsync(cancellationToken, progress);
        }
Пример #5
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static async Task InitializeAsync(AsyncPackage package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as IMenuCommandService;

            var vsMonitorSelection = await package.GetServiceAsync(typeof(IVsMonitorSelection)) as IVsMonitorSelection;

            var componentModel = await package.GetComponentModelAsync();

            _instance = new SolutionRestoreCommand(commandService, vsMonitorSelection, componentModel);
            componentModel.DefaultCompositionService.SatisfyImportsOnce(_instance);
        }
Пример #6
0
        protected override async Task InitializeAsync(
            CancellationToken cancellationToken,
            IProgress <ServiceProgressData> progress)
        {
            var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel;

            componentModel.DefaultCompositionService.SatisfyImportsOnce(this);

            _restoreWorker = new Lazy <ISolutionRestoreWorker>(
                () => componentModel.GetService <ISolutionRestoreWorker>());

            _settings = new Lazy <ISettings>(
                () => componentModel.GetService <ISettings>());

            _solutionManager = new Lazy <IVsSolutionManager>(
                () => componentModel.GetService <IVsSolutionManager>());

            var lockService = new Lazy <INuGetLockService>(
                () => componentModel.GetService <INuGetLockService>());

            var updateSolutionEvent = new VsUpdateSolutionEvent(lockService);

            // Don't use CPS thread helper because of RPS perf regression
            await ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                var dte      = (EnvDTE.DTE) await GetServiceAsync(typeof(SDTE));
                _buildEvents = dte.Events.BuildEvents;
                _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;

                UserAgent.SetUserAgentString(
                    new UserAgentStringBuilder().WithVisualStudioSKU(dte.GetFullVsVersionString()));

                _solutionBuildManager = (IVsSolutionBuildManager5)await GetServiceAsync(typeof(SVsSolutionBuildManager));
                Assumes.Present(_solutionBuildManager);

                _solutionBuildManager.AdviseUpdateSolutionEvents4(updateSolutionEvent, out _updateSolutionEventsCookie4);
            });

            await SolutionRestoreCommand.InitializeAsync(this);

            await base.InitializeAsync(cancellationToken, progress);
        }
Пример #7
0
        protected override async Task InitializeAsync(
            CancellationToken cancellationToken,
            IProgress <ServiceProgressData> progress)
        {
            // Don't use CPS thread helper because of RPS perf regression
            await ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                var dte = (EnvDTE.DTE) await GetServiceAsync(typeof(SDTE));

                UserAgent.SetUserAgentString(
                    new UserAgentStringBuilder().WithVisualStudioSKU(dte.GetFullVsVersionString()));
            });

            _handler = await SolutionRestoreBuildHandler.InitializeAsync(this);

            await SolutionRestoreCommand.InitializeAsync(this);

            await base.InitializeAsync(cancellationToken, progress);
        }