예제 #1
0
            protected override void ErrorCallback(List <KnownException> known, AggregateException unknown)
            {
                if (known != null && known.Count > 0)
                {
                    SaveInProgress = false;
                    string exceptions = "";

                    foreach (Exception e in known)
                    {
                        ExceptionHandler.SendChatMessage(e.Message);
                        exceptions += e.ToString();
                    }

                    LogIO.WriteToLogStart(exceptions);
                }

                if (unknown != null)
                {
                    LogIO.WriteToLogStart("\nConfig operation failed.\n" + unknown.ToString());
                    ExceptionHandler.SendChatMessage("Config operation failed.");
                    SaveInProgress = false;

                    throw unknown;
                }
            }
예제 #2
0
            /// <summary>
            /// Loads the current configuration synchronously.
            /// </summary>
            public ConfigT Load(bool silent = false)
            {
                ConfigT        cfg           = null;
                KnownException loadException = null;

                if (!SaveInProgress)
                {
                    SaveInProgress = true;

                    if (!silent)
                    {
                        ExceptionHandler.SendChatMessage("Loading configuration...");
                    }

                    if (cfgFile.FileExists)
                    {
                        loadException = TryLoad(out cfg);
                        cfg           = ValidateConfig(cfg);
                    }
                    else
                    {
                        cfg = Defaults;
                    }

                    TrySave(cfg);

                    if (loadException != null)
                    {
                        LogIO.TryWriteToLog(loadException.ToString());
                    }
                    else if (!silent)
                    {
                        ExceptionHandler.SendChatMessage("Configuration loaded.");
                    }
                }
                else
                {
                    ExceptionHandler.SendChatMessage("Save operation already in progress.");
                }

                SaveInProgress = false;
                return(cfg);
            }