public async Task <RegistrationLeafResponse> GetRegistrationLeafOrNullAsync( string id, NuGetVersion version, CancellationToken cancellationToken = default) { // Allow read-through caching to happen if it is configured. await _mirror.MirrorAsync(id, version, cancellationToken); var package = await _packages.FindOrNullAsync(id, version, includeUnlisted : true, cancellationToken); if (package == null) { return(null); } return(new BaGetRegistrationLeafResponse { Type = RegistrationLeafResponse.DefaultType, Listed = package.Listed, Downloads = package.Downloads, Published = package.Published, RegistrationLeafUrl = _url.GetRegistrationLeafUrl(id, version), PackageContentUrl = _url.GetPackageDownloadUrl(id, version), RegistrationIndexUrl = _url.GetRegistrationIndexUrl(id) }); }
public virtual RegistrationLeafResponse BuildLeaf(Package package) { var id = package.Id; var version = package.Version; return(new RegistrationLeafResponse { Type = RegistrationLeafResponse.DefaultType, Listed = package.Listed, Published = package.Published, RegistrationLeafUrl = _url.GetRegistrationLeafUrl(id, version), PackageContentUrl = _url.GetPackageDownloadUrl(id, version), RegistrationIndexUrl = _url.GetRegistrationIndexUrl(id) }); }