コード例 #1
0
        public (SorterConfiguration, SorterConfiguration) GetConfiguration(string saveName)
        {
            SorterConfigurationSave configurationSave = _configurationContainer.ConfigurationSaves.FirstOrDefault(x => x.SaveName == saveName);

            if (configurationSave != null)
            {
                return(configurationSave.Party, configurationSave.Other);
            }

            configurationSave = new SorterConfigurationSave {
                SaveName = saveName, Party = new SorterConfiguration(), Other = new SorterConfiguration()
            };
            _configurationContainer.ConfigurationSaves.Add(configurationSave);
            return(configurationSave.Party, configurationSave.Other);
        }
コード例 #2
0
        public void SaveConfigurations()
        {
            _configurationContainer ??= SorterConfigurationJsonService.Load();

            try {
                SorterConfigurationSave configurationSave = _configurationContainer.ConfigurationSaves.FirstOrDefault(x => x.SaveName == States.NewSaveName);
                if (configurationSave == null)
                {
                    if (States.NewSaveName != States.LoadedSaveName)
                    {
                        SorterConfigurationSave loadedConfigurationSave = _configurationContainer.ConfigurationSaves.FirstOrDefault(x => x.SaveName == States.LoadedSaveName);
                        configurationSave = loadedConfigurationSave == null
                                                ? new SorterConfigurationSave()
                                                : new SorterConfigurationSave {
                            SaveName = loadedConfigurationSave.SaveName, Other = loadedConfigurationSave.Other, Party = loadedConfigurationSave.Party, LastSaved = loadedConfigurationSave.LastSaved
                        };
                    }
                    else
                    {
                        configurationSave = new SorterConfigurationSave();
                    }

                    _configurationContainer.ConfigurationSaves.Add(configurationSave);
                }

                configurationSave.SaveName  = States.NewSaveName;
                configurationSave.Party     = States.PartySorterConfiguration;
                configurationSave.Other     = States.OtherSorterConfiguration;
                configurationSave.LastSaved = DateTime.Now;
            } catch (Exception exception) {
                Global.Helpers.ShowError($"YetAnotherPartyOrganiser failed to find sorter configuration for the current save {States.NewSaveName}." + "This shouldn't happen, please report this error by creating an issue on our github page",
                                         "SorterConfigurationManager SaveConfigurations Error",
                                         exception);
            }

            RemoveOldSaveConfigurations();

            SorterConfigurationJsonService.Save(_configurationContainer);
        }