public PackageInfo GetInfo() { if (_info != null) { return(_info); } try { string json = null; using (ZipArchive archive = new ZipArchive(new FileStream(_path, FileMode.Open), ZipArchiveMode.Read)) { ZipArchiveEntry metadataEntry = archive.Entries.Where((ZipArchiveEntry e) => e.FullName == PackageInfo.FileName).First(); using (Stream stream = metadataEntry.Open()) { using (StreamReader reader = new StreamReader(stream)) { json = reader.ReadToEnd(); } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> root = serializer.Deserialize <Dictionary <string, object> >(json); _info = PackageInfoSerializer.Deserialize(root); } catch (Exception) { return(null); } return(_info); }
public List <PackageInfo> ListPackages(string name = null, string version = null, int maxResults = -1) { string separator = null; string query = "packages/list" + PackNameAndVersionQuery(name, version, ref separator); query += $"{separator}limit={maxResults}"; string json = _client.DownloadString(_client.BaseAddress + query); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> root = serializer.Deserialize <Dictionary <string, object> >(json); return(PackageInfoSerializer.Deserialize(Common.JSON.GetJSONValue <ArrayList>(root, "packages", null))); }