/// <summary> /// Basic search /// </summary> public override async Task <IEnumerable <SimpleSearchMetadata> > Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken) { var results = new List <SimpleSearchMetadata>(); foreach (var result in await _rawSearch.Search(searchTerm, filters, skip, take, cancellationToken)) { var version = NuGetVersion.Parse(result["version"].ToString()); var identity = new PackageIdentity(result["id"].ToString(), version); var description = result["description"].ToString(); var allVersions = new List <NuGetVersion>(); foreach (var versionObj in ((JArray)result["versions"])) { allVersions.Add(NuGetVersion.Parse(versionObj["version"].ToString())); } var data = new SimpleSearchMetadata(identity, description, allVersions); results.Add(data); } return(results); }
private void PrintPackage(string packageId, string version, SimpleSearchMetadata package) { /*********************************************** * Package-Name 1.0.0.2010 * Package-Name-Two 2.0.0.2010 ***********************************************/ Console.PrintJustified(0, packageId + " " + version); }
private void PrintPackageDetailed(string packageId, string version, SimpleSearchMetadata package) { /*********************************************** * Package-Name * 1.0.0.2010 * This is the package Summary * * Package-Name-Two * 2.0.0.2010 * This is the second package Summary ***********************************************/ Console.PrintJustified(0, packageId); Console.PrintJustified(1, version); Console.PrintJustified(1, package.Description.ToString() ?? string.Empty); Console.WriteLine(); }
private SimpleSearchMetadata CreatePackageSearchResult(IPackage package) { 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); SimpleSearchMetadata searchMetaData = new SimpleSearchMetadata(identity, summary, nuGetVersions); return(searchMetaData); }