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);
        }
예제 #2
0
        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/");
            }
        }
예제 #3
0
        public override int QueryInt(List <string> path)
        {
            if (path.Count > 1)
            {
                if (String.Equals(path[1], "MaxValue", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(MaxValue.CurrentValue);
                }
                if (String.Equals(path[1], "Bashing", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(bashing);
                }
                if (String.Equals(path[1], "Lethal", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(lethal);
                }
                if (String.Equals(path[1], "Aggravated", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(aggravated);
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return(0);
        }
        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());
                }
            }
        }
예제 #5
0
        public override int QueryInt(List <string> path)
        {
            //only allow this operation if the first column contains string values, so we can use them as a key to find the row we want to modify
            if (path.Count > 2 &&
                columns.Count > 0 &&
                columns[0].defaultValue is TableValue_String)
            {
                string targetRow    = path[1];
                string targetColumn = path[2];
                for (int c = 0; c < columns.Count; ++c)
                {
                    TableColumn column = columns[c];
                    if (String.Equals(column.name, targetColumn, StringComparison.OrdinalIgnoreCase))
                    {
                        for (int r = 0; r < AllRows.Count; ++r)
                        {
                            TableRow row = AllRows[r];
                            if (row.values[0] is TableValue_String rowName)
                            {
                                if (String.Equals(rowName.value, targetRow, StringComparison.OrdinalIgnoreCase))
                                {
                                    if (row.values[c] is TableValue_Numeric targetNumericValue)
                                    {
                                        isCurrentlyIncludedInModFormula = true;
                                        return(targetNumericValue.value.CurrentValue);
                                    }
                                    else if (row.values[c] is TableValue_Range targetRangeValue)
                                    {
                                        if (path.Count > 3)
                                        {
                                            if (String.Equals(path[3], "Short", StringComparison.OrdinalIgnoreCase))
                                            {
                                                isCurrentlyIncludedInModFormula = true;
                                                return(targetRangeValue.shortRange.CurrentValue);
                                            }
                                            else if (String.Equals(path[3], "Medium", StringComparison.OrdinalIgnoreCase))
                                            {
                                                isCurrentlyIncludedInModFormula = true;
                                                return(targetRangeValue.mediumRange.CurrentValue);
                                            }
                                            else if (String.Equals(path[3], "Long", StringComparison.OrdinalIgnoreCase))
                                            {
                                                isCurrentlyIncludedInModFormula = true;
                                                return(targetRangeValue.longRange.CurrentValue);
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return(0);
        }
        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 override string QueryString(List <string> path)
        {
            if (path.Count > 1)
            {
                if (String.Equals(path[1], "ActiveModName", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(sets[ActiveIndex].name);
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return("");
        }
        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);
        }
        public override int QueryInt(List <string> path)
        {
            if (path.Count > 1)
            {
                if (String.Equals(path[1], "Experience", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(experience);
                }
                if (String.Equals(path[1], "Beats", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(beats);
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return(0);
        }
예제 #10
0
        public override string QueryString(List <string> path)
        {
            if (path.Count > 1)
            {
                string targetAdvantage = path[1];
                foreach (Advantage advantage in advantages)
                {
                    if (String.Equals(advantage.name, targetAdvantage, StringComparison.OrdinalIgnoreCase))
                    {
                        isCurrentlyIncludedInModFormula = true;
                        if (advantage is StringAdvantage stringAdvantage)
                        {
                            return(stringAdvantage.value);
                        }
                        break;
                    }
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return("");
        }
예제 #11
0
        public override int QueryInt(List <string> path)
        {
            if (path.Count > 1)
            {
                if (String.Equals(path[1], "MaxValue", StringComparison.OrdinalIgnoreCase))
                {
                    isCurrentlyIncludedInModFormula = true;
                    return(maxValue);
                }
                string targetTrait = path[1];
                foreach (Trait trait in AllTraits)
                {
                    if (String.Equals(trait.name, targetTrait, StringComparison.OrdinalIgnoreCase))
                    {
                        isCurrentlyIncludedInModFormula = true;
                        return(trait.Value.CurrentValue);
                    }
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return(0);
        }
예제 #12
0
        public override int QueryInt(List <string> path)
        {
            if (path.Count > 1)
            {
                string targetAdvantage = path[1];
                foreach (Advantage advantage in advantages)
                {
                    if (String.Equals(advantage.name, targetAdvantage, StringComparison.OrdinalIgnoreCase))
                    {
                        isCurrentlyIncludedInModFormula = true;
                        if (advantage is NumericAdvantage numericAdvantage)
                        {
                            return(numericAdvantage.Value.CurrentValue);
                        }
                        else if (advantage is ArmorAdvantage armorAdvantage)
                        {
                            if (path.Count > 2)
                            {
                                string targetType = path[2];
                                if (String.Equals(targetType, "General", StringComparison.OrdinalIgnoreCase))
                                {
                                    return(armorAdvantage.General.CurrentValue);
                                }
                                else if (String.Equals(targetType, "Ballistic", StringComparison.OrdinalIgnoreCase))
                                {
                                    return(armorAdvantage.Ballistic.CurrentValue);
                                }
                            }
                        }
                        break;
                    }
                }
            }

            StaticErrorLogger.AddQueryError(path);
            return(0);
        }
        public wndContactCreator(Action <string> DisplayMessage, Exception error) : this(DisplayMessage) {
            txtSubject.Text = "Error ";

            txtBody.Text = "Hello, I've encountered this error today: \n" + StaticErrorLogger.FormalizeError(error, "Handled");
        }
예제 #14
0
 /// <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
 }
 override public void ApplyModification(Modification mod, Sheet sheet)
 {
     StaticErrorLogger.AddGenericError("trying to modify a modification component: " + name);
 }