public async void LoadAllChampionsRiotApi() { AllChampions.RemoveAllChampions(); if (MySettings.UserApiKey.Length == 36) { try { StaticRiotApi staticApi = StaticRiotApi.GetInstance(_s.UserApiKey); RiotSharp.StaticDataEndpoint.ChampionListStatic champions = await staticApi.GetChampionsAsync(RiotSharp.Region.euw, RiotSharp.StaticDataEndpoint.ChampionData.info, RiotSharp.Language.en_US); for (int i = 0; i < champions.Champions.Count; i++) { string ChampionName = champions.Champions.Values.ElementAt(i).Name; AllChampions.AddChampion(ChampionName); } } catch (RiotSharpException ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled; AppRuntimeResourcesManager/LoadAllChampionsRiotApi:RiotSharpException"); DisplayPopup("Trouble with loading champions trough the api"); } catch (NullReferenceException ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled; AppRuntimeResourcesManager/LoadAllChampionsRiotApi:NullReferenceException"); DisplayPopup("Internet problem while loading champions"); } } else { DisplayPopup("No correct API key found, get one at https://developer.riotgames.com/"); } }
public static object DeSerializeObject(string fileName) { if (File.Exists(fileName)) { object objectToDeSerialize; Stream stream; try { stream = File.Open(fileName, FileMode.Open); } catch (IOException) { //File is in use, your kind of f****d if I don't write additional code to catch it return(null); } try { BinaryFormatter bFormatter = new BinaryFormatter(); objectToDeSerialize = bFormatter.Deserialize(stream); stream.Close(); return(objectToDeSerialize); } catch (SerializationException ex) { //Attempting to deserialize an empty stream, just delete it as it is void StaticErrorLogger.WriteErrorReport(ex, "Handled! ECS/Serialization/StaticSerializer:DeSerializeObject;"); stream.Close(); File.Delete(fileName); } } return(null); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Save last rdb if (rdbChampionSearchbar.IsChecked == true) { rdbChampionSearchbar_SavePosition(null, null); } else if (rdbTeamChat.IsChecked == true) { rdbTeamChat_SavePosition(null, null); } else if (rdbClientOverlay.IsChecked == true) { rdbClientOverlay_SavePosition(null, null); } if (_lolClientImage != null) { try { _ClientBitmap.Save(StaticSerializer.FullPath_ClientImage); } catch (Exception ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled! Helper_Windows/wndConfigLolClientOverlay.xaml.cs:Window_Closing;"); _displayPopup(ex.ToString()); } } }
public wndErrorHelper(Exception error, Action <string> DisplayPopup) : this() { if (error == null) { throw new ArgumentNullException(); } StaticErrorLogger.WriteErrorReport(_error, "Handled"); _error = error; _displayPopup = DisplayPopup; txtErrorMessage.Text = _error.ToString(); }
public static bool SerializeObject(object objectToSerialize, string fileName) { try { Directory.CreateDirectory(fileName.Substring(0, fileName.LastIndexOf(@"\"))); //Extract directory Stream stream = File.Open(fileName, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, objectToSerialize); stream.Close(); } catch (Exception ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled! ECS/Serialization/StaticSerializer:SerializeObject;"); return(false); } return(true); }
/// <summary> /// Handles the DispatcherUnhandledException event of the App control. /// Makes sure that any unhandled exceptions produce an error report that includes a stack trace. /// </summary> private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { arr.DisplayPopup("An unhandled exception occurred: " + e.Exception.Message); StaticErrorLogger.WriteErrorReport(e.Exception, "Unhandled!"); e.Handled = true; // Prevent default unhandled exception processing }