예제 #1
0
        protected PackagesProviderBase(
            Project project,
            IProjectManager projectManager,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider)
        {
            if (projectManager == null)
            {
                throw new ArgumentNullException("projectManager");
            }

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }

            if (providerServices == null)
            {
                throw new ArgumentNullException("providerServices");
            }

            _progressProvider     = progressProvider;
            _resources            = resources;
            _scriptExecutor       = providerServices.ScriptExecutor;
            _progressWindowOpener = providerServices.ProgressWindow;
            _outputConsole        = new Lazy <IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false));
            ProjectManager        = projectManager;
            _project = project;
        }
예제 #2
0
 public RecentProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IVsPackageManagerFactory packageManagerFactory,
     IPackageRepository recentPackagesRepository,
     IPackageSourceProvider packageSourceProvider,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(
         project,
         localRepository,
         resources,
         packageRepositoryFactory,
         null,
         packageManagerFactory,
         providerServices,
         progressProvider,
         solutionManager)
 {
     _recentPackagesRepository = recentPackagesRepository;
     _packageManagerFactory    = packageManagerFactory;
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
 }
예제 #3
0
        protected PackagesProviderBase(
            IPackageRepository localRepository,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager)
        {
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }

            if (providerServices == null)
            {
                throw new ArgumentNullException("providerServices");
            }

            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            _localRepository  = localRepository;
            _providerServices = providerServices;
            _progressProvider = progressProvider;
            _solutionManager  = solutionManager;
            _resources        = resources;
            _outputConsole    = new Lazy <IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false));
        }
예제 #4
0
        protected PackagesProviderBase(
            IPackageRepository localRepository, 
            ResourceDictionary resources, 
            ProviderServices providerServices, 
            IProgressProvider progressProvider, 
            ISolutionManager solutionManager)
        {
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }

            if (providerServices == null)
            {
                throw new ArgumentNullException("providerServices");
            }

            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            _localRepository = localRepository;
            _providerServices = providerServices;
            _progressProvider = progressProvider;
            _solutionManager = solutionManager;
            _resources = resources;
            _outputConsole = new Lazy<IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false));
        }
예제 #5
0
        public RecentProvider(
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            IPackageRepositoryFactory packageRepositoryFactory,
            IVsPackageManagerFactory packageManagerFactory,
            IPackageRepository recentPackagesRepository,
            IPackageSourceProvider packageSourceProvider,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager) :
            base(
                project,
                localRepository,
                resources,
                packageRepositoryFactory,
                null,
                packageManagerFactory,
                providerServices,
                progressProvider,
                solutionManager)
        {

            _recentPackagesRepository = recentPackagesRepository;
            _packageManagerFactory = packageManagerFactory;
            _packageRepositoryFactory = packageRepositoryFactory;
            _packageSourceProvider = packageSourceProvider;
        }
예제 #6
0
        protected PackagesProviderBase(
            Project project,
            IProjectManager projectManager,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider)
        {
            if (projectManager == null) {
                throw new ArgumentNullException("projectManager");
            }

            if (project == null) {
                throw new ArgumentNullException("project");
            }

            if (resources == null) {
                throw new ArgumentNullException("resources");
            }

            if (providerServices == null) {
                throw new ArgumentNullException("providerServices");
            }

            _progressProvider = progressProvider;
            _resources = resources;
            _scriptExecutor = providerServices.ScriptExecutor;
            _progressWindowOpener = providerServices.ProgressWindow;
            _outputConsole = new Lazy<IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false));
            ProjectManager = projectManager;
            _project = project;
        }
        private PackageManagerWindow(Project project,
                                    DTE dte,
                                    IVsPackageManagerFactory packageManagerFactory,
                                    IPackageRepositoryFactory repositoryFactory,
                                    IPackageSourceProvider packageSourceProvider,
                                    IRecentPackageRepository recentPackagesRepository,
                                    IHttpClientEvents httpClientEvents,
                                    IProductUpdateService productUpdateService,
                                    IPackageRestoreManager packageRestoreManager,
                                    ISolutionManager solutionManager,
                                    IOptionsPageActivator optionPageActivator)
            : base(F1Keyword)
        {

            InitializeComponent();

#if !VS10
            // set unique search guid for VS11
            explorer.SearchCategory = new Guid("{85566D5F-E585-411F-B299-5BF006E9F11E}");
#endif

            _httpClientEvents = httpClientEvents;
            if (_httpClientEvents != null)
            {
                _httpClientEvents.SendingRequest += OnSendingRequest;
            }

            _productUpdateService = productUpdateService;
            _optionsPageActivator = optionPageActivator;
            _activeProject = project;

            // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear 
            // the console the first time an entry is written to it
            var providerServices = new ProviderServices();
            _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider);
            providerServices.OutputConsoleProvider = _smartOutputConsoleProvider;
            _providerSettings = providerServices.ProviderSettings;

            AddUpdateBar(productUpdateService);
            AddRestoreBar(packageRestoreManager);
            InsertDisclaimerElement();
            AdjustSortComboBoxWidth();
            PreparePrereleaseComboBox();

            SetupProviders(
                project,
                dte,
                packageManagerFactory,
                repositoryFactory,
                packageSourceProvider,
                providerServices,
                recentPackagesRepository,
                httpClientEvents,
                solutionManager,
                packageRestoreManager);
        }
예제 #8
0
 public InstalledProvider(
     IVsPackageManager packageManager,
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageManager = packageManager;
 }
예제 #9
0
 public InstalledProvider(
     IVsPackageManager packageManager,
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageManager = packageManager;
 }
예제 #10
0
 public UpdatesProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, progressProvider)
 {
 }
예제 #11
0
 public SolutionInstalledProvider(
     IVsPackageManager packageManager,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager,
     IPackageRestoreManager packageRestoreManager)
     : base(packageManager, null, localRepository, resources, providerServices, progressProvider, solutionManager, packageRestoreManager)
 {
     _userNotifierServices = providerServices.UserNotifierServices;
 }
예제 #12
0
 public SolutionInstalledProvider(
     IVsPackageManager packageManager,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager,
     IPackageRestoreManager packageRestoreManager)
     : base(packageManager, null, localRepository, resources, providerServices, progressProvider, solutionManager, packageRestoreManager)
 {
     _userNotifierServices = providerServices.UserNotifierServices;
 }
예제 #13
0
 public UpdatesProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, progressProvider)
 {
 }
예제 #14
0
 public OnlineProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider) :
     base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
     _packageManagerFactory    = packageManagerFactory;
     _licenseWindowOpener      = providerServices.LicenseWindow;
 }
예제 #15
0
 public OnlineProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _packageManagerFactory = packageManagerFactory;
     _licenseWindowOpener = providerServices.LicenseWindow;
 }
예제 #16
0
 public RecentProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IVsPackageManagerFactory packageManagerFactory,
     IPackageRepository recentPackagesRepository,
     IPackageSourceProvider packageSourceProvider,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, packageRepositoryFactory, null, packageManagerFactory, providerServices, progressProvider)
 {
     _aggregateSource = packageSourceProvider.AggregateSource;
     _recentPackagesRepository = recentPackagesRepository;
     _packageManagerFactory = packageManagerFactory;
     _packageRepositoryFactory = packageRepositoryFactory;
 }
예제 #17
0
        public PackageManagerWindow(DTE dte,
            IVsUIShell vsUIShell,
            IVsPackageManagerFactory packageManagerFactory,
            IPackageRepositoryFactory repositoryFactory,
            IPackageSourceProvider packageSourceProvider,
            ProviderServices providerServices,
            IRecentPackageRepository recentPackagesRepository,
            IHttpClientEvents httpClientEvents,
            ISelectedProviderSettings selectedProviderSettings,
            IProductUpdateService productUpdateService)
            : base(F1Keyword)
        {
            InitializeComponent();

            _httpClientEvents = httpClientEvents;
            if (_httpClientEvents != null) {
                _httpClientEvents.SendingRequest += OnSendingRequest;
            }

            AddUpdateBar(productUpdateService);

            _vsUIShell = vsUIShell;
            _selectedProviderSettings = selectedProviderSettings;
            _productUpdateService = productUpdateService;

            InsertDisclaimerElement();
            AdjustSortComboBoxWidth();

            // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear
            // the console the first time an entry is written to it
            _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider);
            providerServices = new ProviderServices(
                providerServices.LicenseWindow,
                providerServices.ProgressWindow,
                providerServices.ScriptExecutor,
                _smartOutputConsoleProvider);

            SetupProviders(
                dte,
                packageManagerFactory,
                repositoryFactory,
                packageSourceProvider,
                providerServices,
                recentPackagesRepository,
                httpClientEvents);
        }
예제 #18
0
 public OnlineProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(localRepository, resources, providerServices, progressProvider, solutionManager)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
     _packageManagerFactory    = packageManagerFactory;
     _project = project;
 }
예제 #19
0
 public OnlineProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(localRepository, resources, providerServices, progressProvider, solutionManager)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _packageManagerFactory = packageManagerFactory;
     _project = project;
 }
예제 #20
0
 public RecentProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IVsPackageManagerFactory packageManagerFactory,
     IPackageRepository recentPackagesRepository,
     IPackageSourceProvider packageSourceProvider,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, packageRepositoryFactory, null, packageManagerFactory, providerServices, progressProvider)
 {
     _aggregateSource          = packageSourceProvider.AggregateSource;
     _recentPackagesRepository = recentPackagesRepository;
     _packageManagerFactory    = packageManagerFactory;
     _packageRepositoryFactory = packageRepositoryFactory;
 }
예제 #21
0
        public InstalledProvider(
            IVsPackageManager packageManager,
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager)
            : base(localRepository, resources, providerServices, progressProvider, solutionManager)
        {

            if (packageManager == null)
            {
                throw new ArgumentNullException("packageManager");
            }

            _packageManager = packageManager;
            _project = project;
            _userNotifierServices = providerServices.UserNotifierServices;
        }
예제 #22
0
 public SolutionOnlineProvider(
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(null,
          localRepository,
          resources,
          packageRepositoryFactory,
          packageSourceProvider,
          packageManagerFactory,
          providerServices,
          progressProvider,
          solutionManager)
 {
     _userNotifierServices = providerServices.UserNotifierServices;
 }
예제 #23
0
 public SolutionOnlineProvider(
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(null,
         localRepository,
         resources,
         packageRepositoryFactory,
         packageSourceProvider,
         packageManagerFactory,
         providerServices,
         progressProvider,
         solutionManager)
 {
     _userNotifierServices = providerServices.UserNotifierServices;
 }
예제 #24
0
        public InstalledProvider(
            IVsPackageManager packageManager,
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager,
            IPackageRestoreManager packageRestoreManager)
            : base(localRepository, resources, providerServices, progressProvider, solutionManager)
        {
            if (packageManager == null)
            {
                throw new ArgumentNullException("packageManager");
            }

            _packageManager        = packageManager;
            _project               = project;
            _targetFramework       = _project.GetTargetFrameworkName();
            _userNotifierServices  = providerServices.UserNotifierServices;
            _packageRestoreManager = packageRestoreManager;
            _packageRestoreManager.PackagesMissingStatusChanged += OnMissPackagesChanged;
        }
예제 #25
0
        public InstalledProvider(
            IVsPackageManager packageManager,
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager,
            IPackageRestoreManager packageRestoreManager)
            : base(localRepository, resources, providerServices, progressProvider, solutionManager)
        {
            if (packageManager == null)
            {
                throw new ArgumentNullException("packageManager");
            }

            _packageManager = packageManager;
            _project = project;
            _targetFramework = _project.GetTargetFrameworkName();
            _userNotifierServices = providerServices.UserNotifierServices;
            _packageRestoreManager = packageRestoreManager;
            _packageRestoreManager.PackagesMissingStatusChanged += OnMissPackagesChanged;
        }
예제 #26
0
 public UpdatesProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(
         project,
         localRepository,
         resources,
         packageRepositoryFactory,
         packageSourceProvider,
         packageManagerFactory,
         providerServices,
         progressProvider,
         solutionManager)
 {
     _project = project;
     _updateAllUIService = providerServices.UpdateAllUIService;
 }
예제 #27
0
 public UpdatesProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(
         project,
         localRepository,
         resources,
         packageRepositoryFactory,
         packageSourceProvider,
         packageManagerFactory,
         providerServices,
         progressProvider,
         solutionManager)
 {
     _project            = project;
     _updateAllUIService = providerServices.UpdateAllUIService;
 }
예제 #28
0
        private static InstalledProvider CreateInstalledProvider(
            IVsPackageManager packageManager = null,
            IProjectManager projectManager = null,
            Project project = null,
            IScriptExecutor scriptExecutor = null)
        {
            if (packageManager == null) {
                packageManager = new Mock<IVsPackageManager>().Object;
            }

            if (projectManager == null) {
                projectManager = new Mock<IProjectManager>().Object;
            }

            var mockProgressWindowOpener = new Mock<IProgressWindowOpener>();

            if (project == null) {
                project = new Mock<Project>().Object;
            }

            if (scriptExecutor == null) {
                scriptExecutor = new Mock<IScriptExecutor>().Object;
            }

            var services = new ProviderServices(
                null,
                mockProgressWindowOpener.Object,
                scriptExecutor,
                new MockOutputConsoleProvider()
            );

            return new InstalledProvider(packageManager, project, projectManager, new System.Windows.ResourceDictionary(), services, new Mock<IProgressProvider>().Object);
        }
예제 #29
0
        private static InstalledProvider CreateInstalledProvider(
            IVsPackageManager packageManager = null,
            IPackageRepository localRepository = null,
            Project project = null,
            IScriptExecutor scriptExecutor = null,
            ISolutionManager solutionManager = null,
            IPackageRestoreManager packageRestoreManager = null)
        {
            if (packageManager == null)
            {
                packageManager = new Mock<IVsPackageManager>().Object;
            }

            var mockProgressWindowOpener = new Mock<IProgressWindowOpener>();

            if (project == null)
            {
                project = new Mock<Project>().Object;
            }

            if (scriptExecutor == null)
            {
                scriptExecutor = new Mock<IScriptExecutor>().Object;
            }

            var services = new ProviderServices(
                null,
                mockProgressWindowOpener.Object,
                new Mock<IProviderSettings>().Object,
                new Mock<IUpdateAllUIService>().Object,
                scriptExecutor,
                new MockOutputConsoleProvider(),
                new Mock<IVsCommonOperations>().Object
            );

            if (localRepository == null)
            {
                localRepository = new MockPackageRepository();
            }

            if (solutionManager == null)
            {
                solutionManager = new Mock<ISolutionManager>().Object;
            }

            if (packageRestoreManager == null)
            {
                packageRestoreManager = new Mock<IPackageRestoreManager>().Object;
            }

            return new InstalledProvider(
                packageManager,
                project,
                localRepository,
                new System.Windows.ResourceDictionary(),
                services,
                new Mock<IProgressProvider>().Object,
                solutionManager,
                packageRestoreManager);
        }
예제 #30
0
        private static UpdatesProvider CreateUpdatesProvider(
            IVsPackageManager packageManager = null,
            IProjectManager projectManager = null,
            IPackageRepositoryFactory repositoryFactory = null,
            IPackageSourceProvider packageSourceProvider = null,
            Project project = null,
            IScriptExecutor scriptExecutor = null,
            ILicenseWindowOpener licenseWindowOpener = null)
        {
            if (packageManager == null) {
                var packageManagerMock = new Mock<IVsPackageManager>();
                var sourceRepository = new MockPackageRepository();
                packageManagerMock.Setup(p => p.SourceRepository).Returns(sourceRepository);

                packageManager = packageManagerMock.Object;
            }

            if (projectManager == null) {
                projectManager = new Mock<IProjectManager>().Object;
            }

            if (repositoryFactory == null) {
                var repositoryFactoryMock = new Mock<IPackageRepositoryFactory>();
                repositoryFactoryMock.Setup(p => p.CreateRepository(It.IsAny<PackageSource>())).Returns(new MockPackageRepository());
                repositoryFactory = repositoryFactoryMock.Object;
            }

            if (packageSourceProvider == null) {
                var packageSourceProviderMock = new Mock<IPackageSourceProvider>();
                packageSourceProviderMock.Setup(p => p.GetPackageSources()).Returns(
                        new PackageSource[2] {
                            new PackageSource("Test1", "One"),
                            new PackageSource("Test2", "Two")
                        }
                    );
                packageSourceProvider = packageSourceProviderMock.Object;
            }

            var factory = new Mock<IVsPackageManagerFactory>();
            factory.Setup(m => m.CreatePackageManager(It.IsAny<IPackageRepository>())).Returns(packageManager);

            var mockProgressWindowOpener = new Mock<IProgressWindowOpener>();

            if (licenseWindowOpener == null) {
                var mockLicenseWindowOpener = new Mock<ILicenseWindowOpener>();
                licenseWindowOpener = mockLicenseWindowOpener.Object;
            }

            if (project == null) {
                project = new Mock<Project>().Object;
            }

            if (scriptExecutor == null) {
                scriptExecutor = new Mock<IScriptExecutor>().Object;
            }

            var services = new ProviderServices(
                licenseWindowOpener,
                mockProgressWindowOpener.Object,
                scriptExecutor,
                new MockOutputConsoleProvider()
            );

            return new UpdatesProvider(
                project,
                projectManager,
                new System.Windows.ResourceDictionary(),
                repositoryFactory,
                packageSourceProvider,
                factory.Object,
                services,
                new Mock<IProgressProvider>().Object);
        }
예제 #31
0
        private static SolutionUpdatesProvider CreateSolutionUpdatesProvider(
            IVsPackageManager packageManager = null,
            IPackageRepository localRepository = null,
            IPackageRepositoryFactory repositoryFactory = null,
            IPackageSourceProvider packageSourceProvider = null,
            IScriptExecutor scriptExecutor = null,
            ISolutionManager solutionManager = null,
            IUserNotifierServices userNotifierServices = null)
        {

            if (packageManager == null)
            {
                var packageManagerMock = new Mock<IVsPackageManager>();
                var sourceRepository = new MockPackageRepository();
                packageManagerMock.Setup(p => p.SourceRepository).Returns(sourceRepository);

                packageManager = packageManagerMock.Object;
            }

            if (repositoryFactory == null)
            {
                var repositoryFactoryMock = new Mock<IPackageRepositoryFactory>();
                repositoryFactoryMock.Setup(p => p.CreateRepository(It.IsAny<string>())).Returns(new MockPackageRepository());
                repositoryFactory = repositoryFactoryMock.Object;
            }

            if (packageSourceProvider == null)
            {
                var packageSourceProviderMock = new Mock<IPackageSourceProvider>();
                packageSourceProviderMock.Setup(p => p.LoadPackageSources()).Returns(
                        new PackageSource[2] {
                            new PackageSource("Test1", "One"),
                            new PackageSource("Test2", "Two")
                        }
                    );
                packageSourceProvider = packageSourceProviderMock.Object;
            }

            var factory = new Mock<IVsPackageManagerFactory>();
            factory.Setup(m => m.CreatePackageManager(It.IsAny<IPackageRepository>(), true)).Returns(packageManager);

            var mockProgressWindowOpener = new Mock<IProgressWindowOpener>();

            if (userNotifierServices == null)
            {
                var mockWindowServices = new Mock<IUserNotifierServices>();
                userNotifierServices = mockWindowServices.Object;
            }

            if (scriptExecutor == null)
            {
                scriptExecutor = new Mock<IScriptExecutor>().Object;
            }

            if (solutionManager == null)
            {
                solutionManager = new Mock<ISolutionManager>().Object;
            }

            if (userNotifierServices == null)
            {
                userNotifierServices = new Mock<IUserNotifierServices>().Object;
            }

            var services = new ProviderServices(
                userNotifierServices,
                mockProgressWindowOpener.Object,
                new Mock<IProviderSettings>().Object,
                new Mock<IUpdateAllUIService>().Object,
                scriptExecutor,
                new MockOutputConsoleProvider(),
                new Mock<IVsCommonOperations>().Object
            );

            if (localRepository == null)
            {
                localRepository = new Mock<IPackageRepository>().Object;
            }

            return new SolutionUpdatesProvider(
                localRepository,
                new System.Windows.ResourceDictionary(),
                repositoryFactory,
                packageSourceProvider,
                factory.Object,
                services,
                new Mock<IProgressProvider>().Object,
                solutionManager);
        }
예제 #32
0
        private void SetupProviders(Project activeProject,
                                    DTE dte,
                                    IVsPackageManagerFactory packageManagerFactory,
                                    IPackageRepositoryFactory packageRepositoryFactory,
                                    IPackageSourceProvider packageSourceProvider,
                                    ProviderServices providerServices,
                                    IPackageRepository recentPackagesRepository,
                                    IHttpClientEvents httpClientEvents,
                                    ISolutionManager solutionManager,
                                    IPackageRestoreManager packageRestoreManager)
        {

            // This package manager is not used for installing from a remote source, and therefore does not need a fallback repository for resolving dependencies
            IVsPackageManager packageManager = packageManagerFactory.CreatePackageManager(ServiceLocator.GetInstance<IPackageRepository>(), useFallbackForDependencies: false);

            IPackageRepository localRepository;

            // we need different sets of providers depending on whether the dialog is open for solution or a project
            OnlineProvider onlineProvider;
            InstalledProvider installedProvider;
            UpdatesProvider updatesProvider;
            OnlineProvider recentProvider;

            if (activeProject == null)
            {
                Title = String.Format(
                    CultureInfo.CurrentUICulture,
                    NuGet.Dialog.Resources.Dialog_Title,
                    dte.Solution.GetName() + ".sln");

                localRepository = packageManager.LocalRepository;

                onlineProvider = new SolutionOnlineProvider(
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                installedProvider = new SolutionInstalledProvider(
                    packageManager,
                    localRepository,
                    Resources,
                    providerServices,
                    httpClientEvents,
                    solutionManager,
                    packageRestoreManager);

                updatesProvider = new SolutionUpdatesProvider(
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                recentProvider = new SolutionRecentProvider(
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageManagerFactory,
                    recentPackagesRepository,
                    packageSourceProvider,
                    providerServices,
                    httpClientEvents,
                    solutionManager);
            }
            else
            {
                IProjectManager projectManager = packageManager.GetProjectManager(activeProject);
                localRepository = projectManager.LocalRepository;

                Title = String.Format(
                    CultureInfo.CurrentUICulture,
                    NuGet.Dialog.Resources.Dialog_Title,
                    activeProject.GetDisplayName());

                onlineProvider = new OnlineProvider(
                    activeProject,
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                installedProvider = new InstalledProvider(
                    packageManager,
                    activeProject,
                    localRepository,
                    Resources,
                    providerServices,
                    httpClientEvents,
                    solutionManager,
                    packageRestoreManager);

                updatesProvider = new UpdatesProvider(
                    activeProject,
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                recentProvider = new RecentProvider(
                    activeProject,
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageManagerFactory,
                    recentPackagesRepository,
                    packageSourceProvider,
                    providerServices,
                    httpClientEvents,
                    solutionManager);
            }

            explorer.Providers.Add(installedProvider);
            explorer.Providers.Add(onlineProvider);
            explorer.Providers.Add(updatesProvider);
            explorer.Providers.Add(recentProvider);

            installedProvider.IncludePrerelease =
                onlineProvider.IncludePrerelease =
                updatesProvider.IncludePrerelease =
                recentProvider.IncludePrerelease = _providerSettings.IncludePrereleasePackages;

            // retrieve the selected provider from the settings
            int selectedProvider = Math.Min(3, _providerSettings.SelectedProvider);
            explorer.SelectedProvider = explorer.Providers[selectedProvider];
        }
        private PackageManagerWindow(Project project,
                                    DTE dte,
                                    IVsPackageManagerFactory packageManagerFactory,
                                    IPackageRepositoryFactory repositoryFactory,
                                    IPackageSourceProvider packageSourceProvider,
                                    IHttpClientEvents httpClientEvents,
                                    IProductUpdateService productUpdateService,
                                    IPackageRestoreManager packageRestoreManager,
                                    ISolutionManager solutionManager,
                                    IOptionsPageActivator optionPageActivator,
                                    IDeleteOnRestartManager deleteOnRestartManager,
                                    IVsShell4 vsRestarter,
                                    string dialogParameters)
            : base(F1Keyword)
        {

            InitializeComponent();

#if !VS10
            // set unique search guid for VS11
            explorer.SearchCategory = new Guid("{85566D5F-E585-411F-B299-5BF006E9F11E}");
#endif

            _httpClientEvents = httpClientEvents;
            if (_httpClientEvents != null)
            {
                _httpClientEvents.SendingRequest += OnSendingRequest;
            }

            _productUpdateService = productUpdateService;
            _optionsPageActivator = optionPageActivator;
            _activeProject = project;

            // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear 
            // the console the first time an entry is written to it
            var providerServices = new ProviderServices();
            _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider);
            providerServices.OutputConsoleProvider = _smartOutputConsoleProvider;
            _providerSettings = providerServices.ProviderSettings;
            _updateAllUIService = providerServices.UpdateAllUIService;
            providerServices.ProgressWindow.UpgradeNuGetRequested += (_, __) =>
                {
                    Close();
                    productUpdateService.Update();
                };

            AddUpdateBar(productUpdateService);
            AddRestoreBar(packageRestoreManager);
            var restartRequestBar = AddRestartRequestBar(deleteOnRestartManager, vsRestarter);
            InsertDisclaimerElement();
            AdjustSortComboBoxWidth();
            PreparePrereleaseComboBox();
            InsertUpdateAllButton(providerServices.UpdateAllUIService);

            SetupProviders(
                project,
                dte,
                packageManagerFactory,
                repositoryFactory,
                packageSourceProvider,
                providerServices,
                httpClientEvents,
                solutionManager,
                packageRestoreManager,
                restartRequestBar);

            ProcessDialogParameters(dialogParameters);
        }
        private void SetupProviders(Project activeProject,
                                    DTE dte,
                                    IVsPackageManagerFactory packageManagerFactory,
                                    IPackageRepositoryFactory packageRepositoryFactory,
                                    IPackageSourceProvider packageSourceProvider,
                                    ProviderServices providerServices,
                                    IHttpClientEvents httpClientEvents,
                                    ISolutionManager solutionManager,
                                    IPackageRestoreManager packageRestoreManager,
                                    RestartRequestBar restartRequestBar)
        {
            IVsPackageManager packageManager = packageManagerFactory.CreatePackageManagerToManageInstalledPackages();

            IPackageRepository localRepository;

            // we need different sets of providers depending on whether the dialog is open for solution or a project
            OnlineProvider onlineProvider;
            InstalledProvider installedProvider;
            UpdatesProvider updatesProvider;

            if (activeProject == null)
            {
                Title = String.Format(
                    CultureInfo.CurrentUICulture,
                    NuGet.Dialog.Resources.Dialog_Title,
                    dte.Solution.GetName() + ".sln");

                localRepository = packageManager.LocalRepository;

                onlineProvider = new SolutionOnlineProvider(
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                installedProvider = new SolutionInstalledProvider(
                    packageManager,
                    localRepository,
                    Resources,
                    providerServices,
                    httpClientEvents,
                    solutionManager,
                    packageRestoreManager);

                updatesProvider = new SolutionUpdatesProvider(
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);
            }
            else
            {
                IProjectManager projectManager = packageManager.GetProjectManager(activeProject);
                localRepository = projectManager.LocalRepository;

                Title = String.Format(
                    CultureInfo.CurrentUICulture,
                    NuGet.Dialog.Resources.Dialog_Title,
                    activeProject.GetDisplayName());

                onlineProvider = new OnlineProvider(
                    activeProject,
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);

                installedProvider = new InstalledProvider(
                    packageManager,
                    activeProject,
                    localRepository,
                    Resources,
                    providerServices,
                    httpClientEvents,
                    solutionManager,
                    packageRestoreManager);

                updatesProvider = new UpdatesProvider(
                    activeProject,
                    localRepository,
                    Resources,
                    packageRepositoryFactory,
                    packageSourceProvider,
                    packageManagerFactory,
                    providerServices,
                    httpClientEvents,
                    solutionManager);
            }

            explorer.Providers.Add(installedProvider);
            explorer.Providers.Add(onlineProvider);
            explorer.Providers.Add(updatesProvider);

            installedProvider.IncludePrerelease =
                onlineProvider.IncludePrerelease =
                updatesProvider.IncludePrerelease = _providerSettings.IncludePrereleasePackages;

            installedProvider.ExecuteCompletedCallback =
                onlineProvider.ExecuteCompletedCallback =
                updatesProvider.ExecuteCompletedCallback = restartRequestBar.CheckForUnsuccessfulUninstall;

            Loaded += (o, e) => restartRequestBar.CheckForUnsuccessfulUninstall();
        }
예제 #35
0
        private void SetupProviders(DTE dte,
            IVsPackageManagerFactory packageManagerFactory,
            IPackageRepositoryFactory packageRepositoryFactory,
            IPackageSourceProvider packageSourceProvider,
            ProviderServices providerServices,
            IPackageRepository recentPackagesRepository,
            IHttpClientEvents httpClientEvents)
        {
            IVsPackageManager packageManager = packageManagerFactory.CreatePackageManager();
            Project activeProject = dte.GetActiveProject();

            // Create a cached project manager so that checking for installed packages is fast
            IProjectManager projectManager = packageManager.GetProjectManager(activeProject);

            var recentProvider = new RecentProvider(
                activeProject,
                projectManager,
                Resources,
                packageRepositoryFactory,
                packageManagerFactory,
                recentPackagesRepository,
                packageSourceProvider,
                providerServices,
                httpClientEvents);

            var updatesProvider = new UpdatesProvider(
                activeProject,
                projectManager,
                Resources,
                packageRepositoryFactory,
                packageSourceProvider,
                packageManagerFactory,
                providerServices,
                httpClientEvents);

            var onlineProvider = new OnlineProvider(
                activeProject,
                projectManager,
                Resources,
                packageRepositoryFactory,
                packageSourceProvider,
                packageManagerFactory,
                providerServices,
                httpClientEvents);

            var installedProvider = new InstalledProvider(
                packageManager,
                activeProject,
                projectManager,
                Resources,
                providerServices,
                httpClientEvents);

            explorer.Providers.Add(installedProvider);
            explorer.Providers.Add(onlineProvider);
            explorer.Providers.Add(updatesProvider);
            explorer.Providers.Add(recentProvider);

            // retrieve the selected provider from the settings
            int selectedProvider = Math.Min(3, _selectedProviderSettings.SelectedProvider);
            explorer.SelectedProvider = explorer.Providers[selectedProvider];
        }