Exemple #1
0
            /// <summary>
            /// Saves a given configuration to the save file in parallel.
            /// </summary>
            public void SaveStart(ConfigT cfg, bool silent = false)
            {
                if (!SaveInProgress)
                {
                    if (!silent)
                    {
                        ExceptionHandler.SendChatMessage("Saving configuration...");
                    }
                    SaveInProgress = true;

                    EnqueueTask(() =>
                    {
                        cfg.Validate();
                        KnownException exception = TrySave(cfg);

                        if (exception != null)
                        {
                            EnqueueAction(() =>
                                          SaveFinish(false, silent));

                            throw exception;
                        }
                        else
                        {
                            EnqueueAction(() =>
                                          SaveFinish(true, silent));
                        }
                    });
                }
                else
                {
                    ExceptionHandler.SendChatMessage("Save operation already in progress.");
                }
            }
Exemple #2
0
            /// <summary>
            /// Saves the current configuration synchronously.
            /// </summary>
            public void Save(ConfigT cfg)
            {
                if (!SaveInProgress)
                {
                    cfg.Validate();
                    KnownException exception = TrySave(cfg);

                    if (exception != null)
                    {
                        throw exception;
                    }
                }
            }
Exemple #3
0
            private ConfigT ValidateConfig(ConfigT cfg)
            {
                if (cfg != null)
                {
                    if (cfg.VersionID != Defaults.VersionID)
                    {
                        EnqueueAction(() => ExceptionHandler.SendChatMessage("Config version mismatch. Some settings may have " +
                                                                             "been reset. A backup of the original config file will be made."));

                        Backup();
                    }

                    cfg.Validate();
                    return(cfg);
                }
                else
                {
                    EnqueueAction(() => ExceptionHandler.SendChatMessage("Unable to load configuration."));
                    return(Defaults);
                }
            }