private static List <VersionInfo> GetVersions(
            FindLocalPackagesResource localResource,
            LocalPackageInfo package,
            SearchFilter filter,
            ILogger log,
            CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            // apply the filters to the version list returned
            var versions = localResource.FindPackagesById(package.Identity.Id, log, token)
                           .Where(v => filter.IncludePrerelease || !v.Identity.Version.IsPrerelease)
                           .Select(p => new VersionInfo(p.Identity.Version, downloadCount: 0))
                           .OrderByDescending(v => v.Version, VersionComparer.Default)
                           .ToList();

            // Add in the current package if it does not already exist
            if (!versions.Any(v => v.Version == package.Identity.Version))
            {
                var packageVersionInfo = new VersionInfo(package.Identity.Version, downloadCount: 0)
                {
                    PackageSearchMetadata = new LocalPackageSearchMetadata(package)
                };

                versions.Add(packageVersionInfo);
            }

            return(versions);
        }
        public LocalDownloadResource(FindLocalPackagesResource localResource)
        {
            if (localResource == null)
            {
                throw new ArgumentNullException(nameof(localResource));
            }

            _localResource = localResource;
        }
Exemple #3
0
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            FindLocalPackagesResource curResource = null;

            if (await source.GetFeedType(token) == FeedType.FileSystemV3)
            {
                curResource = new FindLocalPackagesResourceV3(source.PackageSource.Source);
            }

            return(new Tuple <bool, INuGetResource>(curResource != null, curResource));
        }
Exemple #4
0
        public LocalDependencyInfoResource(FindLocalPackagesResource localResource, SourceRepository source)
        {
            if (localResource == null)
            {
                throw new ArgumentNullException(nameof(localResource));
            }

            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _localResource = localResource;
            _source        = source;
        }
Exemple #5
0
 public LocalDownloadResource(FindLocalPackagesResource localResource)
     : this(source : null, localResource)
 {
 }