Exemplo n.º 1
0
        // Non-private only to facilitate testing.
        internal NuGetUIContext(
            IServiceBroker serviceBroker,
            IReconnectingNuGetSearchService nuGetSearchService,
            IVsSolutionManager solutionManager,
            NuGetSolutionManagerServiceWrapper solutionManagerService,
            NuGetPackageManager packageManager,
            UIActionEngine uiActionEngine,
            IPackageRestoreManager packageRestoreManager,
            IOptionsPageActivator optionsPageActivator,
            IUserSettingsManager userSettingsManager,
            NuGetSourcesServiceWrapper sourceService)
        {
            ServiceBroker             = serviceBroker;
            ReconnectingSearchService = nuGetSearchService;
            SolutionManager           = solutionManager;
            _solutionManagerService   = solutionManagerService;
            PackageManager            = packageManager;
            UIActionEngine            = uiActionEngine;
            PackageManager            = packageManager;
            PackageRestoreManager     = packageRestoreManager;
            OptionsPageActivator      = optionsPageActivator;
            UserSettingsManager       = userSettingsManager;
            _sourceService            = sourceService;

            ServiceBroker.AvailabilityChanged += OnAvailabilityChanged;
            SolutionManager.ActionsExecuted   += OnActionsExecuted;
        }
Exemplo n.º 2
0
        // Non-private only to facilitate testing.
        internal NuGetUIContext(
            ISourceRepositoryProvider sourceProvider,
            IServiceBroker serviceBroker,
            IVsSolutionManager solutionManager,
            NuGetSolutionManagerServiceWrapper solutionManagerService,
            NuGetPackageManager packageManager,
            UIActionEngine uiActionEngine,
            IPackageRestoreManager packageRestoreManager,
            IOptionsPageActivator optionsPageActivator,
            IUserSettingsManager userSettingsManager,
            IEnumerable <IVsPackageManagerProvider> packageManagerProviders)
        {
            SourceProvider          = sourceProvider;
            ServiceBroker           = serviceBroker;
            SolutionManager         = solutionManager;
            _solutionManagerService = solutionManagerService;
            PackageManager          = packageManager;
            UIActionEngine          = uiActionEngine;
            PackageManager          = packageManager;
            PackageRestoreManager   = packageRestoreManager;
            OptionsPageActivator    = optionsPageActivator;
            UserSettingsManager     = userSettingsManager;
            PackageManagerProviders = packageManagerProviders;

            ServiceBroker.AvailabilityChanged += OnAvailabilityChanged;
            SolutionManager.ActionsExecuted   += OnActionsExecuted;
        }
Exemplo n.º 3
0
        private INuGetUIContext CreateUIContext(params NuGetProject[] projects)
        {
            var packageManager = new NuGetPackageManager(
                SourceRepositoryProvider.Value,
                Settings.Value,
                SolutionManager,
                DeleteOnRestartManager.Value);

            var actionEngine = new UIActionEngine(
                SourceRepositoryProvider.Value,
                packageManager,
                LockService.Value);

            // only pick up at most three integrated package managers
            const int MaxPackageManager       = 3;
            var       packageManagerProviders = PackageManagerProviderUtility.Sort(
                PackageManagerProviders, MaxPackageManager);

            var context = new NuGetUIContext(
                SourceRepositoryProvider.Value,
                SolutionManager,
                packageManager,
                actionEngine,
                PackageRestoreManager.Value,
                OptionsPageActivator.Value,
                SolutionUserOptions,
                packageManagerProviders)
            {
                Projects = projects
            };

            return(context);
        }
Exemplo n.º 4
0
        public static async ValueTask <NuGetUIContext> CreateAsync(
            IServiceBroker serviceBroker,
            ISourceRepositoryProvider sourceRepositoryProvider,
            ISettings settings,
            IVsSolutionManager solutionManager,
            IPackageRestoreManager packageRestoreManager,
            IOptionsPageActivator optionsPageActivator,
            IUserSettingsManager userSettingsManager,
            IDeleteOnRestartManager deleteOnRestartManager,
            IEnumerable <IVsPackageManagerProvider> packageManagerProviders,
            INuGetLockService lockService,
            CancellationToken cancellationToken)
        {
            Assumes.NotNull(serviceBroker);
            Assumes.NotNull(sourceRepositoryProvider);
            Assumes.NotNull(settings);
            Assumes.NotNull(solutionManager);
            Assumes.NotNull(packageRestoreManager);
            Assumes.NotNull(optionsPageActivator);
            Assumes.NotNull(userSettingsManager);
            Assumes.NotNull(deleteOnRestartManager);
            Assumes.NotNull(packageManagerProviders);
            Assumes.NotNull(lockService);

            cancellationToken.ThrowIfCancellationRequested();

            var solutionManagerServiceWrapper = new NuGetSolutionManagerServiceWrapper();
            INuGetSolutionManagerService solutionManagerService = await GetSolutionManagerServiceAsync(serviceBroker, cancellationToken);

            // The initial Swap(...) should return a null implementation of the interface that does not require disposal.
            // However, there's no harm in following form.
            using (solutionManagerServiceWrapper.Swap(solutionManagerService))
            {
            }

            var packageManager = new NuGetPackageManager(
                sourceRepositoryProvider,
                settings,
                solutionManager,
                deleteOnRestartManager);

            var actionEngine = new UIActionEngine(
                sourceRepositoryProvider,
                packageManager,
                lockService);

            return(new NuGetUIContext(
                       sourceRepositoryProvider,
                       serviceBroker,
                       solutionManager,
                       solutionManagerServiceWrapper,
                       packageManager,
                       actionEngine,
                       packageRestoreManager,
                       optionsPageActivator,
                       userSettingsManager,
                       packageManagerProviders));
        }
 public VisualStudioUIContext(
     NuGetPackage package,
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable<NuGet.ProjectManagement.NuGetProject> projects) :
     base(sourceProvider, solutionManager, packageManager, uiActionEngine, packageRestoreManager, optionsPageActivator, projects)
 {
     _package = package;
 }
 public StandaloneUIContext(
     string settingsFile,
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable<NuGet.ProjectManagement.NuGetProject> projects) :
     base(sourceProvider, solutionManager, packageManager, uiActionEngine, packageRestoreManager, optionsPageActivator, projects)
 {
     _settingsFile = settingsFile;            
     LoadSettings();
 }
        public INuGetUIContext Create(string settingsFile, IEnumerable<NuGetProject> projects)
        {
            if (String.IsNullOrEmpty(settingsFile))
            {
                throw new ArgumentException("settingsFile");
            }

            if (projects == null || !projects.Any())
            {
                throw new ArgumentNullException("projects");
            }

            NuGetPackageManager packageManager = new NuGetPackageManager(_repositoryProvider, _settings, _solutionManager);
            UIActionEngine actionEngine = new UIActionEngine(_repositoryProvider, packageManager);

            return new StandaloneUIContext(settingsFile, _repositoryProvider, _solutionManager, packageManager, actionEngine, _restoreManager, _optionsPage, projects);
        }
Exemplo n.º 8
0
 public NuGetUIContextBase(
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable <NuGetProject> projects)
 {
     _sourceProvider        = sourceProvider;
     _solutionManager       = solutionManager;
     _packageManager        = packageManager;
     _uiActionEngine        = uiActionEngine;
     _packageManager        = packageManager;
     _packageRestoreManager = packageRestoreManager;
     _optionsPageActivator  = optionsPageActivator;
     _projects = projects.ToArray();
 }
 public NuGetUIContextBase(
     ISourceRepositoryProvider sourceProvider, 
     ISolutionManager solutionManager, 
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable<NuGetProject> projects)
 {
     _sourceProvider = sourceProvider;
     _solutionManager = solutionManager;
     _packageManager = packageManager;
     _uiActionEngine = uiActionEngine;
     _packageManager = packageManager;
     _packageRestoreManager = packageRestoreManager;
     _optionsPageActivator = optionsPageActivator;
     _projects = projects.ToArray();
 }
Exemplo n.º 10
0
 protected NuGetUIContextBase(
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable <NuGetProject> projects,
     IEnumerable <IVsPackageManagerProvider> packageManagerProviders)
 {
     SourceProvider          = sourceProvider;
     SolutionManager         = solutionManager;
     PackageManager          = packageManager;
     UIActionEngine          = uiActionEngine;
     PackageManager          = packageManager;
     PackageRestoreManager   = packageRestoreManager;
     OptionsPageActivator    = optionsPageActivator;
     _projects               = projects.ToArray();
     PackageManagerProviders = packageManagerProviders;
 }
Exemplo n.º 11
0
 public NuGetUIContext(
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IUserSettingsManager userSettingsManager,
     IEnumerable <IVsPackageManagerProvider> packageManagerProviders)
 {
     SourceProvider          = sourceProvider;
     SolutionManager         = solutionManager;
     PackageManager          = packageManager;
     UIActionEngine          = uiActionEngine;
     PackageManager          = packageManager;
     PackageRestoreManager   = packageRestoreManager;
     OptionsPageActivator    = optionsPageActivator;
     UserSettingsManager     = userSettingsManager;
     PackageManagerProviders = packageManagerProviders;
 }
        public INuGetUIContext Create(NuGetPackage package, IEnumerable<NuGet.ProjectManagement.NuGetProject> projects)
        {
            if (projects == null || !projects.Any())
            {
                throw new ArgumentNullException("projects");
            }

            NuGetPackageManager packageManager = new NuGetPackageManager(_repositoryProvider, _settings, _solutionManager);
            UIActionEngine actionEngine = new UIActionEngine(_repositoryProvider, packageManager);

            return new VisualStudioUIContext(
                package,
                _repositoryProvider, 
                _solutionManager, 
                packageManager, 
                actionEngine, 
                _restoreManager, 
                _optionsPage, 
                projects);
        }
Exemplo n.º 13
0
        public static async ValueTask <NuGetUIContext> CreateAsync(
            IServiceBroker serviceBroker,
            ISourceRepositoryProvider sourceRepositoryProvider,
            ISettings settings,
            IVsSolutionManager solutionManager,
            IPackageRestoreManager packageRestoreManager,
            IOptionsPageActivator optionsPageActivator,
            IUserSettingsManager userSettingsManager,
            IDeleteOnRestartManager deleteOnRestartManager,
            IEnumerable <IVsPackageManagerProvider> packageManagerProviders,
            INuGetLockService lockService,
            CancellationToken cancellationToken)
        {
            Assumes.NotNull(serviceBroker);
            Assumes.NotNull(sourceRepositoryProvider);
            Assumes.NotNull(settings);
            Assumes.NotNull(solutionManager);
            Assumes.NotNull(packageRestoreManager);
            Assumes.NotNull(optionsPageActivator);
            Assumes.NotNull(userSettingsManager);
            Assumes.NotNull(deleteOnRestartManager);
            Assumes.NotNull(packageManagerProviders);
            Assumes.NotNull(lockService);

            cancellationToken.ThrowIfCancellationRequested();

            var solutionManagerServiceWrapper = new NuGetSolutionManagerServiceWrapper();
            INuGetSolutionManagerService solutionManagerService = await GetSolutionManagerServiceAsync(serviceBroker, cancellationToken);

            // The initial Swap(...) should return a null implementation of the interface that does not require disposal.
            // However, there's no harm in following form.
            using (solutionManagerServiceWrapper.Swap(solutionManagerService))
            {
            }

            var sourceServiceWrapper           = new NuGetSourcesServiceWrapper();
            INuGetSourcesService sourceService = await GetSourceServiceAsync(serviceBroker, cancellationToken);

            using (sourceServiceWrapper.Swap(sourceService))
            {
            }

#pragma warning disable CA2000 // Dispose objects before losing scope - NuGetUIContext owns the instance and should dispose it.
            var searchService = await NuGetSearchServiceReconnector.CreateAsync(serviceBroker, NuGetUIThreadHelper.JoinableTaskFactory, cancellationToken);

#pragma warning restore CA2000 // Dispose objects before losing scope

            var packageManager = new NuGetPackageManager(
                sourceRepositoryProvider,
                settings,
                solutionManager,
                deleteOnRestartManager);

            var actionEngine = new UIActionEngine(
                sourceRepositoryProvider,
                packageManager,
                lockService);

            return(new NuGetUIContext(
                       serviceBroker,
                       searchService.Object,
                       solutionManager,
                       solutionManagerServiceWrapper,
                       packageManager,
                       actionEngine,
                       packageRestoreManager,
                       optionsPageActivator,
                       userSettingsManager,
                       packageManagerProviders,
                       sourceServiceWrapper));
        }