public static int parseRequirements(Package pack) { String requirement; if ((requirement = pack.requirement) != null) { // Begin parsing the requirement String[] requirements = Utils.explode(requirement, new char[] { '\\' }); String version = requirements[0]; String arch = requirements[1]; String release = requirements[2]; String install = requirements[3]; // Offline package-version selector. List<PackageVersion> versions = APIConnector.makeRequest<List<PackageVersion>>(APIConnector.getPackageVersionsByIdRequestString(pack.name)); List<PackageVersion> candidates = new List<PackageVersion>(); foreach (PackageVersion pv in versions) { if (meetsReq(pv.version, version) && meetsReq(pv.archType, arch) && meetsReq(pv.releaseType, release) && meetsReq(pv.installationType, install)) { candidates.Add(pv); } } if (candidates.Count > 0) { if (candidates.Count == 1) { return candidates[0].packageVersionId; } else { // Get the latest version amongst the candidates List<PackageVersion> vers = candidates.OrderBy(o => o.version).ToList(); return vers[0].packageVersionId; } } } return -1; }
public static void writeDetailedPackage(Package pack) { Console.WriteLine(String.Format("{0, -15}", "Name") + " : " + pack.name); Console.WriteLine(String.Format("{0, -15}", "Friendly name") + " : " + pack.friendlyName); Console.WriteLine(String.Format("{0, -15}", "Description") + " : " + pack.description + "\n"); Console.WriteLine(String.Format("{0, -15}", "Category") + " : " + pack.packageType); Console.WriteLine(String.Format("{0, -15}", "Manufacturer") + " : " + pack.manufacturer); Console.WriteLine(String.Format("{0, -15}", "Website") + " : " + pack.website); Console.WriteLine(String.Format("{0, -15}", "Created") + " : " + pack.created); }