internal bool LoadRiotMasteryData(string version) { bool success = false; try { string file; file = string.Format(@"{0}\Data\Masteries\getMasteries.{1}.bin", PublicStaticVariables.thisAppDataDir, version); string dir = string.Format(@"{0}\Data\Masteries", PublicStaticVariables.thisAppDataDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } StreamReader re = new StreamReader(file); try { JsonTextReader reader = new JsonTextReader(re); JsonSerializer se = new JsonSerializer(); object parsedData = se.Deserialize(reader); masteries = JsonConvert.DeserializeObject <MasteryListStatic>(parsedData.ToString()); this.version = masteries.Version; MasteryDataCorrections.RunCorrections(masteries); success = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); success = false; } finally { re.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); success = false; } return(success); }
public bool DownloadListOfMasteries(string inputVersion = null) { bool success = false; // Get all Items for NA try { // Setup RiotApi var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey); //Get all Items if (inputVersion == null) { masteries = staticApi.GetMasteries(RiotSharp.Region.na, MasteryData.all); } else { masteries = staticApi.GetMasteries(RiotSharp.Region.na, inputVersion, MasteryData.all); } version = masteries.Version; StoreRiotMasteryData(masteries); MasteryDataCorrections.RunCorrections(masteries); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this MessageBox.Show(ex.ToString()); success = false; } return(success); }