private async Task <List <int> > GetGameIdsByTagAsync( string tag, Func <string, Task <JObject> > getJsonObject, bool isBackupUsed) { var jsonObj = await getJsonObject(tag); var gameIds = jsonObj.ToObject <Dictionary <int, object> >().Keys.ToList(); if (gameIds.Count == 0) { throw new TagUnavailableException(SteamSpyUtils.GetTagErrorMessage(isBackupUsed), tag); } return(gameIds); }
private async Task <JObject> GetGameIdsByTagFromBackupAsync(string tag) { try { string jsonStr; using (var r = new StreamReader($"Backups/Tags/{tag}.json")) { jsonStr = await r.ReadToEndAsync(); } return(JObject.Parse(jsonStr)); } catch (Exception e) when( e is FileNotFoundException || e is DirectoryNotFoundException || e is IOException || e is JsonReaderException) { throw new TagUnavailableException(SteamSpyUtils.GetTagErrorMessage(true), tag, e); } }
private async Task <JObject> FetchGameIdsByTagAsync(string tag) { var url = SteamSpyUtils.GetGamesByTagUrl(tag); return(await _remoteApiService.GetJsonObjectAsync(url, SteamSpyUtils.ApiName)); }