internal VSSolutionManager(
            IAsyncServiceProvider asyncServiceProvider,
            IProjectSystemCache projectSystemCache,
            NuGetProjectFactory projectSystemFactory,
            ICredentialServiceProvider credentialServiceProvider,
            IVsProjectAdapterProvider vsProjectAdapterProvider,
            ILogger logger,
            Lazy <ISettings> settings,
            INuGetFeatureFlagService featureFlagService,
            JoinableTaskContext joinableTaskContext)
        {
            Assumes.Present(asyncServiceProvider);
            Assumes.Present(projectSystemCache);
            Assumes.Present(projectSystemFactory);
            Assumes.Present(credentialServiceProvider);
            Assumes.Present(vsProjectAdapterProvider);
            Assumes.Present(logger);
            Assumes.Present(settings);
            Assumes.Present(featureFlagService);
            Assumes.Present(joinableTaskContext);

            _asyncServiceProvider      = asyncServiceProvider;
            _projectSystemCache        = projectSystemCache;
            _projectSystemFactory      = projectSystemFactory;
            _credentialServiceProvider = credentialServiceProvider;
            _vsProjectAdapterProvider  = vsProjectAdapterProvider;
            _logger             = logger;
            _settings           = settings;
            _featureFlagService = featureFlagService;
            _initLock           = new NuGetLockService(joinableTaskContext);
            _dte             = new(() => asyncServiceProvider.GetDTEAsync(), NuGetUIThreadHelper.JoinableTaskFactory);
            _asyncVSSolution = new(() => asyncServiceProvider.GetServiceAsync <SVsSolution, IVsSolution>(), NuGetUIThreadHelper.JoinableTaskFactory);
        }
 public VsPathContextProvider(
     IAsyncServiceProvider asyncServiceProvider,
     Lazy <ISettings> settings,
     Lazy <IVsSolutionManager> solutionManager,
     Lazy <ILogger> logger,
     Lazy <IMachineWideSettings> machineWideSettings,
     INuGetTelemetryProvider telemetryProvider)
 {
     _asyncServiceprovider = asyncServiceProvider ?? throw new ArgumentNullException(nameof(asyncServiceProvider));
     _settings             = settings ?? throw new ArgumentNullException(nameof(settings));
     _solutionManager      = solutionManager ?? throw new ArgumentNullException(nameof(solutionManager));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     _getLockFileOrNullAsync = BuildIntegratedProjectUtility.GetLockFileOrNull;
     if (machineWideSettings == null)
     {
         throw new ArgumentNullException(nameof(machineWideSettings));
     }
     _projectContext = new Lazy <INuGetProjectContext>(() => new VSAPIProjectContext
     {
         PackageExtractionContext = new PackageExtractionContext(
             PackageSaveMode.Defaultv2,
             PackageExtractionBehavior.XmlDocFileSaveMode,
             ClientPolicyContext.GetClientPolicy(_settings.Value, NullLogger.Instance),
             NullLogger.Instance)
     });
     _userWideSettings  = new Microsoft.VisualStudio.Threading.AsyncLazy <ISettings>(() => Task.FromResult(Settings.LoadDefaultSettings(null, null, machineWideSettings.Value)), NuGetUIThreadHelper.JoinableTaskFactory);
     _telemetryProvider = telemetryProvider ?? throw new ArgumentNullException(nameof(telemetryProvider));
 }
        protected PowerShellHost(string name, IRestoreEvents restoreEvents, IRunspaceManager runspaceManager)
        {
            _restoreEvents   = restoreEvents;
            _runspaceManager = runspaceManager;

            // TODO: Take these as ctor arguments
            var componentModel = NuGetUIThreadHelper.JoinableTaskFactory.Run(ServiceLocator.GetComponentModelAsync);

            _sourceRepositoryProvider = componentModel.GetService <ISourceRepositoryProvider>();
            _solutionManager          = new Lazy <IVsSolutionManager>(() => componentModel.GetService <IVsSolutionManager>());
            _settings = new Lazy <ISettings>(() => componentModel.GetService <ISettings>());
            _deleteOnRestartManager  = new Lazy <IDeleteOnRestartManager>(() => componentModel.GetService <IDeleteOnRestartManager>());
            _scriptExecutor          = new Lazy <IScriptExecutor>(() => componentModel.GetService <IScriptExecutor>());
            _restoreProgressReporter = new Lazy <IRestoreProgressReporter>(() => componentModel.GetService <IRestoreProgressReporter>());

            _dte = new Lazy <DTE>(() => ServiceLocator.GetInstance <DTE>());
            _sourceControlManagerProvider = new Lazy <ISourceControlManagerProvider>(
                () => componentModel.GetService <ISourceControlManagerProvider>());
            _commonOperations = new Lazy <ICommonOperations>(() => componentModel.GetService <ICommonOperations>());
            _name             = name;
            IsCommandEnabled  = true;

            InitializeSources();

            _sourceRepositoryProvider.PackageSourceProvider.PackageSourcesChanged += PackageSourceProvider_PackageSourcesChanged;
            _restoreEvents.SolutionRestoreCompleted += RestoreEvents_SolutionRestoreCompleted;

            _vsMonitorSelection = new Microsoft.VisualStudio.Threading.AsyncLazy <IVsMonitorSelection>(
                async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // get the UI context cookie for the debugging mode
                var vsMonitorSelection = ServiceLocator.GetGlobalService <IVsMonitorSelection, IVsMonitorSelection>();

                var guidCmdUI = VSConstants.UICONTEXT.SolutionExists_guid;
                vsMonitorSelection.GetCmdUIContextCookie(
                    ref guidCmdUI, out _solutionExistsCookie);

                return(vsMonitorSelection);
            },
                ThreadHelper.JoinableTaskFactory);
        }