public override async Task <IEnumerable <SourcePackageDependencyInfo> > ResolvePackages( string packageId, NuGetFramework projectFramework, ILogger log, CancellationToken token) { token.ThrowIfCancellationRequested(); try { var packages = await _feedParser.FindPackagesByIdAsync(packageId, log, token); var results = new List <SourcePackageDependencyInfo>(); foreach (var package in packages) { results.Add(CreateDependencyInfo(package, projectFramework)); } return(results); } catch (Exception ex) { // Wrap exceptions coming from the server with a user friendly message var error = String.Format(CultureInfo.CurrentUICulture, Strings.Protocol_PackageMetadataError, packageId, _source); throw new FatalProtocolException(error, ex); } }
public async Task <IEnumerable <VersionInfo> > GetVersions( V2FeedPackageInfo package, SearchFilter filter, Common.ILogger log, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); // apply the filters to the version list returned var packages = await _feedParser.FindPackagesByIdAsync( package.Id, filter.IncludeDelisted, filter.IncludePrerelease, log, cancellationToken); var uniqueVersions = new HashSet <NuGetVersion>(); var results = new List <VersionInfo>(); foreach (var versionPackage in packages.OrderByDescending(p => p.Version)) { if (uniqueVersions.Add(versionPackage.Version)) { var versionInfo = new VersionInfo(versionPackage.Version, versionPackage.DownloadCount) { PackageSearchMetadata = new PackageSearchMetadataV2Feed(versionPackage) }; results.Add(versionInfo); } } return(results); }
public override async Task <IEnumerable <IPackageSearchMetadata> > GetMetadataAsync( string packageId, bool includePrerelease, bool includeUnlisted, Common.ILogger log, CancellationToken token) { var packages = await _feedParser.FindPackagesByIdAsync(packageId, includeUnlisted, includePrerelease, log, token); return(packages.Select(p => new PackageSearchMetadataV2Feed(p)).ToList()); }
public override async Task <IEnumerable <NuGetVersion> > GetVersions(string packageId, bool includePrerelease, bool includeUnlisted, ILogger log, CancellationToken token) { token.ThrowIfCancellationRequested(); try { var packages = await _feedParser.FindPackagesByIdAsync(packageId, includeUnlisted, includePrerelease, log, token); return(packages.Select(p => p.Version).ToArray()); } catch (Exception ex) { throw new FatalProtocolException(string.Format(CultureInfo.CurrentCulture, Strings.Protocol_PackageMetadataError, packageId, _source), ex); } }
public override async Task <IEnumerable <IPackageSearchMetadata> > GetMetadataAsync( string packageId, bool includePrerelease, bool includeUnlisted, SourceCacheContext sourceCacheContext, Common.ILogger log, CancellationToken token) { var packages = await _feedParser.FindPackagesByIdAsync(packageId, includeUnlisted, includePrerelease, sourceCacheContext, log, token); var metadataCache = new MetadataReferenceCache(); var filter = new SearchFilter(includePrerelease); filter.IncludeDelisted = includeUnlisted; return(packages.Select(p => V2FeedUtilities.CreatePackageSearchResult(p, metadataCache, filter, _feedParser, log, token)).ToList()); }
private static async Task <IEnumerable <VersionInfo> > GetVersions( V2FeedPackageInfo package, MetadataReferenceCache metadataCache, SearchFilter filter, V2FeedParser feedParser, Common.ILogger log, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); using (var sourceCacheContext = new SourceCacheContext()) { // Update http source cache context MaxAge so that it can always go online to fetch // latest version of packages. sourceCacheContext.MaxAge = DateTimeOffset.UtcNow; // apply the filters to the version list returned var packages = await feedParser.FindPackagesByIdAsync( package.Id, filter.IncludeDelisted, filter.IncludePrerelease, sourceCacheContext, log, cancellationToken); var uniqueVersions = new HashSet <NuGetVersion>(); var results = new List <VersionInfo>(); foreach (var versionPackage in packages.OrderByDescending(p => p.Version)) { if (uniqueVersions.Add(versionPackage.Version)) { var versionInfo = new VersionInfo(versionPackage.Version, versionPackage.DownloadCount) { PackageSearchMetadata = new PackageSearchMetadataV2Feed(versionPackage, metadataCache) }; results.Add(versionInfo); } } return(results); } }