protected void Fetch() { if (FormMain.ProfileLoaded && string.IsNullOrWhiteSpace(FormMain.CurrentProfile.SteamWebApiKey)) { using (SteamKeyDialog dialog = new SteamKeyDialog()) { dialog.ShowDialog(); } } if (FormMain.ProfileLoaded && !string.IsNullOrWhiteSpace(FormMain.CurrentProfile.SteamWebApiKey)) { Logger.Info("Updating profile using Steam Web API!"); string json; using (WebClient wc = new WebClient()) { wc.Encoding = Encoding.UTF8; json = wc.DownloadString(string.Format(Constants.SteamWebApiOwnedGames, FormMain.CurrentProfile.SteamWebApiKey, SteamId)); } ownedGamesObject = JsonConvert.DeserializeObject <GetOwnedGamesObject>(json); } else { doc = GameList.FetchGameList(SteamId); } }
protected void Fetch() { if (FormMain.ProfileLoaded && string.IsNullOrWhiteSpace(FormMain.CurrentProfile.SteamWebApiKey)) { using (SteamKeyDialog dialog = new SteamKeyDialog()) { dialog.ShowDialog(); } } if (FormMain.ProfileLoaded && !string.IsNullOrWhiteSpace(FormMain.CurrentProfile.SteamWebApiKey)) { Logger.Info("Updating profile using Steam Web API!"); HttpClient client = new HttpClient(); using (Stream s = client.GetStreamAsync(string.Format(Constants.SteamWebApiOwnedGames, FormMain.CurrentProfile.SteamWebApiKey, SteamId)).Result) using (StreamReader sr = new StreamReader(s)) using (JsonReader reader = new JsonTextReader(sr)) { JsonSerializer serializer = new JsonSerializer(); ownedGamesObject = serializer.Deserialize <GetOwnedGamesObject>(reader); } } else { doc = GameList.FetchGameList(SteamId); } }