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());
        }
        public override async Task <IPackageSearchMetadata> GetMetadataAsync(
            PackageIdentity package,
            SourceCacheContext sourceCacheContext,
            Common.ILogger log,
            CancellationToken token)
        {
            var v2Package = await _feedParser.GetPackage(package, sourceCacheContext, log, token);

            if (v2Package != null)
            {
                var metadataCache = new MetadataReferenceCache();
                var filter        = new SearchFilter(v2Package.Version.IsPrerelease);
                filter.IncludeDelisted = !v2Package.IsListed;

                return(V2FeedUtilities.CreatePackageSearchResult(v2Package, metadataCache, filter, _feedParser, log, token));
            }
            return(null);
        }
示例#3
0
        public async override Task <IEnumerable <IPackageSearchMetadata> > SearchAsync(
            string searchTerm,
            SearchFilter filters,
            int skip,
            int take,
            Common.ILogger log,
            CancellationToken cancellationToken)
        {
            var query = await _feedParser.Search(
                searchTerm,
                filters,
                skip,
                take,
                log,
                cancellationToken);

            // NuGet.Server does not group packages by id, this resource needs to handle it.
            var results = query.GroupBy(p => p.Id)
                          .Select(group => group.OrderByDescending(p => p.Version).First())
                          .Select(package => V2FeedUtilities.CreatePackageSearchResult(package, filters, _feedParser, log, cancellationToken));

            return(results.ToList());
        }