public IPackageDetails GetPackage(IRepository packageRepository, string packageId, string version) { Argument.IsNotNull(() => packageRepository); var nuGetRepository = _repositoryCacheService.GetNuGetRepository(packageRepository); var semanticVersion = SemanticVersion.Parse(version); var package = nuGetRepository.FindPackage(packageId, semanticVersion); if (package != null) { return(_packageCacheService.GetPackageDetails(nuGetRepository, package, !string.IsNullOrWhiteSpace(semanticVersion.SpecialVersion))); } return(null); }
public IEnumerable <IPackageDetails> GetPackages(IRepository packageRepository, bool allowPrereleaseVersions, string filter = null, int skip = 0, int take = 10) { Argument.IsNotNull(() => packageRepository); try { Log.Debug("Getting {0} packages starting from {1}, which contains \"{2}\"", take, skip, filter); var nuGetRepository = _repositoryCacheService.GetNuGetRepository(packageRepository); return(nuGetRepository.FindFiltered(filter, allowPrereleaseVersions, skip, take) .Select(package => _packageCacheService.GetPackageDetails(package))); } catch (Exception exception) { Log.Warning(exception); return(Enumerable.Empty <PackageDetails>()); } }
public IEnumerable <IPackageDetails> SearchForUpdates(bool?allowPrerelease = null, bool authenticateIfRequired = true) { var scopeManagers = new List <ScopeManager <AuthenticationScope> >(); try { Log.Debug("Searching for updates, allowPrerelease = {0}, authenticateIfRequired = {1}", allowPrerelease, authenticateIfRequired); var sourceRepositories = _repositoryService.GetSourceRepositories(); foreach (var repository in sourceRepositories) { var scopeManager = ScopeManager <AuthenticationScope> .GetScopeManager(repository.Source.GetSafeScopeName(), () => new AuthenticationScope(authenticateIfRequired)); scopeManagers.Add(scopeManager); } var availableUpdates = new List <IPackageDetails>(); var packageRepository = _repositoryCacheService.GetNuGetRepository(_repositoryService.GetSourceAggregateRepository()); var packages = _repositoryCacheService.GetNuGetRepository(_repositoryService.LocalRepository).GetPackages(); foreach (var package in packages) { var prerelease = allowPrerelease ?? package.IsPrerelease(); var packageUpdates = packageRepository.GetUpdates(new[] { package }, prerelease, false).Select(x => _packageCacheService.GetPackageDetails(packageRepository, x, allowPrerelease ?? true)); availableUpdates.AddRange(packageUpdates); } Log.Debug("Finished searching for updates, found '{0}' updates", availableUpdates.Count); return(availableUpdates); } finally { foreach (var scopeManager in scopeManagers) { scopeManager.Dispose(); } scopeManagers.Clear(); } }
public PackageManager(IRepository sourceRepository, IRepositoryCacheService repositoryCacheService, string path) : base(repositoryCacheService.GetNuGetRepository(sourceRepository), path) { PackageInstalling += (sender, args) => NotifyOperationStarting(args.InstallPath, PackageOperationType.Install, _packageCacheService.GetPackageDetails(repositoryCacheService.GetNuGetRepository(sourceRepository), args.Package, true)); PackageInstalled += (sender, args) => NotifyOperationFinished(args.InstallPath, PackageOperationType.Install, _packageCacheService.GetPackageDetails(repositoryCacheService.GetNuGetRepository(sourceRepository), args.Package, true)); PackageUninstalling += (sender, args) => NotifyOperationStarting(args.InstallPath, PackageOperationType.Uninstall, _packageCacheService.GetPackageDetails(repositoryCacheService.GetNuGetRepository(sourceRepository), args.Package, true)); PackageUninstalled += (sender, args) => NotifyOperationFinished(args.InstallPath, PackageOperationType.Uninstall, _packageCacheService.GetPackageDetails(repositoryCacheService.GetNuGetRepository(sourceRepository), args.Package, true)); }
public IEnumerable <IPackageDetails> SearchForUpdates(bool?allowPrerelease = null, bool authenticateIfRequired = true) { var availableUpdates = new List <IPackageDetails>(); using (_authenticationSilencerService.AuthenticationRequiredScope(authenticateIfRequired)) { var packageRepository = _repositoryCacheService.GetNuGetRepository(_repositoryService.GetSourceAggregateRepository()); var packages = _repositoryCacheService.GetNuGetRepository(_repositoryService.LocalRepository).GetPackages(); foreach (var package in packages) { var prerelease = allowPrerelease ?? package.IsPrerelease(); var packageUpdates = packageRepository.GetUpdates(new[] { package }, prerelease, false).Select(x => _packageCacheService.GetPackageDetails(x)); availableUpdates.AddRange(packageUpdates); } } return(availableUpdates); }