private UISearchMetadata CreatePackageSearchResult(IPackage package, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var versions = V2Client.FindPackagesById(package.Id); if (!versions.Any()) { versions = new[] { package }; } string id = package.Id; NuGetVersion version = V2Utilities.SafeToNuGetVer(package.Version); string summary = package.Summary; IEnumerable <NuGetVersion> nuGetVersions = versions.Select(p => V2Utilities.SafeToNuGetVer(p.Version)); if (string.IsNullOrWhiteSpace(summary)) { summary = package.Description; } Uri iconUrl = package.IconUrl; PackageIdentity identity = new PackageIdentity(id, version); UISearchMetadata searchMetaData = new UISearchMetadata(identity, summary, iconUrl, nuGetVersions, null); return(searchMetaData); }
private UISearchMetadata GetVisualStudioUISearchResult(JObject package, bool includePrerelease) { string id = package.Value <string>(Properties.PackageId); NuGetVersion version = NuGetVersion.Parse(package.Value <string>(Properties.LatestVersion)); PackageIdentity topPackage = new PackageIdentity(id, version); Uri iconUrl = GetUri(package, Properties.IconUrl); // get other versions var versionList = new List <NuGetVersion>(); var versions = package.Value <JArray>(Properties.Versions); if (versions != null) { if (versions[0].Type == JTokenType.String) { // TODO: this part should be removed once the new end point is up and running. versionList = versions .Select(v => NuGetVersion.Parse(v.Value <string>())) .ToList(); } else { versionList = versions .Select(v => NuGetVersion.Parse(v.Value <string>("version"))) .ToList(); } if (!includePrerelease) { // remove prerelease version if includePrelease is false versionList.RemoveAll(v => v.IsPrerelease); } } if (!versionList.Contains(version)) { versionList.Add(version); } IEnumerable <NuGetVersion> nuGetVersions = versionList; string summary = package.Value <string>(Properties.Summary); if (string.IsNullOrWhiteSpace(summary)) { // summary is empty. Use its description instead. summary = package.Value <string>(Properties.Description); } UISearchMetadata searchResult = new UISearchMetadata(topPackage, summary, iconUrl, nuGetVersions, null); return(searchResult); }
public SiteExtensionInfo(UISearchMetadata data) { Id = data.Identity.Id; Title = data.Identity.Id; Type = SiteExtensionType.Gallery; Summary = data.LatestPackageMetadata.Summary; Description = data.LatestPackageMetadata.Description; Version = data.Identity.Version.ToNormalizedString(); ProjectUrl = data.LatestPackageMetadata.ProjectUrl == null ? null : data.LatestPackageMetadata.ProjectUrl.ToString(); IconUrl = data.LatestPackageMetadata.IconUrl == null ? "https://www.siteextensions.net/Content/Images/packageDefaultIcon-50x50.png" : data.LatestPackageMetadata.IconUrl.ToString(); LicenseUrl = data.LatestPackageMetadata.LicenseUrl == null ? null : data.LatestPackageMetadata.LicenseUrl.ToString(); Authors = data.LatestPackageMetadata.Authors.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); PublishedDateTime = data.LatestPackageMetadata.Published; IsLatestVersion = data.Identity.Version.Equals(data.LatestPackageMetadata.Identity.Version); DownloadCount = data.LatestPackageMetadata.DownloadCount; }
public async Task TestAllSearchTitle(string SourceUrl) { SourceRepository repo = GetSourceRepository(SourceUrl); UISearchResource resource = repo.GetResource <UISearchResource>(); SearchFilter filter = new SearchFilter(); string searchTerm = "Json"; IEnumerable <UISearchMetadata> uiSearchResults = await resource.Search(searchTerm, filter, 0, 100, new CancellationToken()); UISearchMetadata metadata = uiSearchResults.Where(e => StringComparer.OrdinalIgnoreCase.Equals("newtonsoft.json", e.Identity.Id)).Single(); // TODO: check the title value once the server is updated Assert.True(!String.IsNullOrEmpty(metadata.Title)); Assert.True(!String.IsNullOrEmpty(metadata.LatestPackageMetadata.Title)); }
private async Task<SiteExtensionInfo> ConvertLocalPackageToSiteExtensionInfo(UISearchMetadata package, bool checkLatest) { if (package == null) { return null; } var info = new SiteExtensionInfo(package); SetLocalInfo(info); await TryCheckLocalPackageLatestVersionFromRemote(info, checkLatest); return info; }
private async Task<SiteExtensionInfo> ConvertRemotePackageToSiteExtensionInfo(UISearchMetadata package, string feedUrl) { return await CheckRemotePackageLatestVersion(new SiteExtensionInfo(package), feedUrl); }
private PSSearchMetadata GetPSSearch(UISearchMetadata item) { return(new PSSearchMetadata(item.Identity, item.Versions, item.Summary)); }