private UISearchMetadata CreatePackageSearchResult(IPackage package, SearchFilter filters, CancellationToken cancellationToken) { var id = package.Id; var version = V2Utilities.SafeToNuGetVer(package.Version); var title = package.Title; var summary = package.Summary; if (string.IsNullOrWhiteSpace(summary)) { summary = package.Description; } if (string.IsNullOrEmpty(title)) { title = id; } var iconUrl = package.IconUrl; var identity = new PackageIdentity(id, version); var versions = new Lazy <Task <IEnumerable <VersionInfo> > >(() => GetVersionInfoAsync(package, filters, cancellationToken)); var searchMetaData = new UISearchMetadata(identity, title, summary, iconUrl, versions, UIMetadataResourceV2.GetVisualStudioUIPackageMetadata(package)); return(searchMetaData); }
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token) { UIMetadataResourceV2 resource = null; var v2repo = await GetRepository(source, token); if (v2repo != null) { resource = new UIMetadataResourceV2(v2repo); } return new Tuple<bool, INuGetResource>(resource != null, resource); }
public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token) { UIMetadataResourceV2 resource = null; var v2repo = await GetRepository(source, token); if (v2repo != null) { resource = new UIMetadataResourceV2(v2repo); } return(new Tuple <bool, INuGetResource>(resource != null, resource)); }
private async Task <UISearchMetadata> CreatePackageSearchResult(IPackage package, SearchFilter filters, CancellationToken cancellationToken) { return(await Task.Run(() => { cancellationToken.ThrowIfCancellationRequested(); // apply the filters to the version list returned var versions = V2Client.FindPackagesById(package.Id) .Where(p => filters.IncludeDelisted || !p.Published.HasValue || p.Published.Value.Year > 1901) .Where(v => filters.IncludePrerelease || String.IsNullOrEmpty(v.Version.SpecialVersion)).ToArray(); if (!versions.Any()) { versions = new[] { package }; } string id = package.Id; NuGetVersion version = V2Utilities.SafeToNuGetVer(package.Version); string title = package.Title; string summary = package.Summary; var nuGetVersions = versions.Select(p => new VersionInfo(V2Utilities.SafeToNuGetVer(p.Version), p.DownloadCount)); if (String.IsNullOrWhiteSpace(summary)) { summary = package.Description; } if (String.IsNullOrEmpty(title)) { title = id; } Uri iconUrl = package.IconUrl; PackageIdentity identity = new PackageIdentity(id, version); UISearchMetadata searchMetaData = new UISearchMetadata(identity, title, summary, iconUrl, nuGetVersions, UIMetadataResourceV2.GetVisualStudioUIPackageMetadata(package)); return searchMetaData; })); }