Exemplo n.º 1
0
        protected static void CreateMergedTestAppConfig(out string mainFile, out string userFile)
        {
            mainFile = "initMainSettings".TestRunUniqueName(Toml.FileExtension);
            userFile = "initUserSettings".TestRunUniqueName(Toml.FileExtension);

            var main         = TestData.TestAppSettings.GlobalSettings;
            var userSettings = TestData.TestAppSettings.User1Settings;
            var user         = Toml.Create();

            user.Add(nameof(main.User), userSettings);

            // Act
            Toml.WriteFile(main, mainFile);
            Toml.WriteFile(user, userFile);
        }
Exemplo n.º 2
0
        private static void SetUpGlobalSettings()
        {
            // save/load settings
            string settingsPath = Path.Combine(DataDir, @"settings.toml");

            if (!File.Exists(settingsPath) && !new DirectoryInfo(DataDir).Attributes.HasFlag(FileAttributes.ReadOnly))
            {
                Toml.WriteFile <GlobalSettings>(new GlobalSettings(), settingsPath);
            }

            if (File.Exists(settingsPath))
            {
                GlobalSettings = Toml.ReadFile <GlobalSettings>(settingsPath);
            }
        }
Exemplo n.º 3
0
        public void WriteFile_WithFloat_WritesCultureInvariant()
        {
            // Arrange
            var tt = Toml.Create();

            tt.Add("TheFloat", 1.2);

            // Act
            Toml.WriteFile(tt, this.fn);

            // Assert
            var s = File.ReadAllText(this.fn);

            s.Should().Be("TheFloat = 1.2\r\n");
        }
Exemplo n.º 4
0
        public static List <AvailableResolver> GetAllResolversWithFilters()
        {
            var resolvers      = new List <AvailableResolver>();
            var dnscryptFolder = Path.Combine(Directory.GetCurrentDirectory(), Global.DnsCryptProxyFolder);
            // we use a second config file
            var tmpToml = Path.Combine(dnscryptFolder, "_tmp_.toml");

            if (File.Exists(tmpToml))
            {
                File.Delete(tmpToml);
            }
            File.Copy(Path.Combine(dnscryptFolder, Global.DnsCryptConfigurationFile), Path.Combine(dnscryptFolder, tmpToml));
            var config = Toml.ReadFile <DnscryptProxyConfiguration>(tmpToml);

            //clear the array
            config.server_names = null;
            Toml.WriteFile(config, tmpToml);
            var result = ExecuteWithArguments("-config _tmp_.toml -list -json");

            if (!result.Success)
            {
                return(resolvers);
            }
            if (string.IsNullOrEmpty(result.StandardOutput))
            {
                return(resolvers);
            }
            try
            {
                var res = JsonConvert.DeserializeObject <List <AvailableResolver> >(result.StandardOutput);
                if (res.Count > 0)
                {
                    resolvers = res;
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
            finally
            {
                if (File.Exists(tmpToml))
                {
                    File.Delete(tmpToml);
                }
            }
            return(resolvers);
        }
Exemplo n.º 5
0
        public static DiscoConfig GetConfig()
        {
            /*
             * The "current directory" is where the
             * DesktopGoose executable is
             */

            string discoConfig = Path.Combine(Directory.GetCurrentDirectory(), @"Assets\Mods\DiscoGoose\config.toml");

            if (!File.Exists(discoConfig))
            {
                Toml.WriteFile(new DiscoConfig(), discoConfig);
            }

            return(Toml.ReadFile <DiscoConfig>(discoConfig));
        }
Exemplo n.º 6
0
        private CurrentSettings LoadSettingsFromPath(string path)
        {
            var tomlFile = Toml.ReadFile(path, TomlHelper.DefaultSettings);
            var version  = tomlFile["Version"].Get <string>();

            // Create backup before migration
            if (version != CurrentSettingsVersion)
            {
                Toml.WriteFile(tomlFile, Path.Combine(SettingsDirectory, $"audioband.settings.{version}"), TomlHelper.DefaultSettings);
                var settings = SettingsMigration.MigrateSettings <CurrentSettings>(tomlFile.Get(SettingsTypeTable[version]), version, CurrentSettingsVersion);

                SerializeSettings(settings);
                return(settings);
            }

            return(tomlFile.Get <CurrentSettings>());
        }
Exemplo n.º 7
0
        public void WriteFile_WritesFile()
        {
            // Arrange
            var foo = new Foo()
            {
                X = 1
            };

            // Act
            Toml.WriteFile(foo, fn);

            // Assert
            File.Exists(this.fn).Should().Be(true);
            var read = Toml.ReadFile <Foo>(this.fn);

            read.X.Should().Be(1);
        }
Exemplo n.º 8
0
        private void WriteTomlFile(string fileName)
        {
            var config = new Configuration()
            {
                EnableDebug = true,
                Server      = new Server()
                {
                    Timeout = TimeSpan.FromMinutes(1)
                },
                Client = new Client()
                {
                    ServerAddress = "http://127.0.0.1:8080"
                },
            };

            Toml.WriteFile(config, fileName);
        }
Exemplo n.º 9
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_config != null)
                {
                    Toml.WriteFile(_config, "config.toml", _tomlSettings);
                    _config = null;
                }

                _waveIn?.StopRecording();
                _waveIn?.Dispose();
                _waveIn = null;

                _speechRecognizer?.Dispose();
                _speechRecognizer = null;

                _skFont?.Dispose();
                _skFont = null;

                _skStrokePaint?.Dispose();
                _skStrokePaint = null;

                _skFillPaint?.Dispose();
                _skFillPaint = null;

                _skScreenSurface?.Dispose();
                _skScreenSurface = null;

                _skScreenRenderTarget?.Dispose();
                _skScreenRenderTarget = null;

                _skContext?.Dispose();
                _skContext = null;

                _skInterface?.Dispose();
                _skInterface = null;

                _tkContext?.Dispose();
                _tkContext = null;

                _tkWindow?.Dispose();
                _tkWindow = null;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Saves global settings to specified file.
        /// </summary>
        /// <param name="path">Path to settings file.</param>
        /// <exception cref="System.InvalidOperationException">Settings are not instantiated.</exception>
        public static void Save(string path)
        {
            if (Instance == null)
            {
                throw new InvalidOperationException("Settings are not instantiated.");
            }

            Instance.Saving();

            try
            {
                Toml.WriteFile <AppSettings>(AppSettings.Instance, path);
            }
            catch (Exception e)
            {
                MessageBox.Show($"Cannot save prefs: {e.Message}");
            }
        }
Exemplo n.º 11
0
        public void Save(string filepath = "")
        {
            if (!String.IsNullOrEmpty(filepath))
            {
                FilePath = filepath;
            }

            var data = new Dictionary <string, object>()
            {
                { Defines.KeyConfig, InputMonitor.GetConfig() },
                { Defines.TouchConfig, TouchSettings.GetConfig() },
                { Defines.GameConfig, GameSettingsScreen.GetConfig() }
            };

            Toml.WriteFile(data, Defines.ConfigFile);

            // Should this go here? I don't see why we would save if we didn't want to apply it immediately
            UpdateGlobals();
        }
Exemplo n.º 12
0
        public void Write_WithCustomObject_WritesCorrectFileContent()
        {
            // Arrange
            using (var filename = TestFileName.Create("test", ".toml"))
            {
                // Act
                var obj = new Configuration();
                Toml.WriteFile(obj, filename);

                // Assert
                File.ReadAllText(filename).ShouldBeSemanticallyEquivalentTo(
                    @"
EnableDebug = false
[Server]
Timeout = 2m
[Client]
ServerAddress = ""http://localhost:8082""");
            }
        }
Exemplo n.º 13
0
        public static void SavePrivateData <T>(this Simulation simulation, T data, string group, string category, string instance)
        {
            var path = GetPrivatePath(
                simulation,
                new[] { group, category, instance },
                PRIVATE_DATA_FILE_NAME
                );

            if (EqualityComparer <T> .Default.Equals(data, default))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                return;
            }

            Toml.WriteFile(data, path);
        }
Exemplo n.º 14
0
        private void SaveConfig()
        {
            TomlTable appSettings = Toml.Create();

            appSettings.Add("ListenPort", ServerPort);

            if (ConfigTable.ContainsKey("Application"))
            {
                ConfigTable.Remove("Application");
            }

            ConfigTable.Add("Application", appSettings);

            foreach (var item in Items)
            {
                (item as IConfigViewModel).SaveConfig(ConfigTable);
            }

            Toml.WriteFile(ConfigTable, CONFIG_FILE);
        }
Exemplo n.º 15
0
        public static bool LoadGUISettings()
        {
            bool fileExists = File.Exists(Path.Combine(GlobalVariables.DataDir, @"GUIsettings.toml"));

            try //catches toml read errors
            {
                Params = Toml.ReadFile <GuiGlobalParams>(Path.Combine(GlobalVariables.DataDir, @"GUIsettings.toml"));
            }
            catch
            {
                Params = new GuiGlobalParams(); //create an instance
                Toml.WriteFile(Params, Path.Combine(GlobalVariables.DataDir, @"GUIsettings.toml"), MetaMorpheusTask.tomlConfig);
            }

            if (GlobalVariables.MetaMorpheusVersion.Contains("Not a release version"))
            {
                Params.AskAboutUpdating = false;
            }
            return(fileExists);
        }
Exemplo n.º 16
0
        private void PostModsLoaded()
        {
            try
            {
                // load configs
                var path = Path.Combine(API.Helper.getModDirectory(this), "config.toml");
                if (File.Exists(path))
                {
                    config = Toml.ReadFile <Config>(path, tomlSettings);
                }
                else
                {
                    config = new Config();
                }

                Toml.WriteFile(config, path, tomlSettings);

                // initialize hat image
                switch (config.HatMode)
                {
                case Config.HatType.None:
                    hat = new Hat(new Bitmap(1, 1), GetDefaultHatSettings(tomlSettings));
                    hat.Image.SetPixel(0, 0, Color.Transparent);
                    break;

                case Config.HatType.Default:
                    hat = new Hat(Resources.DefaultImage, GetDefaultHatSettings(tomlSettings));
                    break;

                case Config.HatType.Custom:
                    hat = ReadFromHatfile(config.CustomHatPath, config.Overrides, tomlSettings);
                    break;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"Error initializing {Name}: {e}",
                                Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                hat = default;
            }
        }
Exemplo n.º 17
0
        public void UseTransaction_ExternalChangesAreLoaded()
        {
            using (var scenario = SingleConfigFileScenario.Setup(nameof(UseTransaction_ExternalChangesAreLoaded)))
            {
                // Arrange
                var cfg = scenario.CreateConfig();
                cfg.StartTransaction();
                int       originalValue = cfg.Get(c => c.X);
                const int newValue      = 123;
                Toml.WriteFile(new SingleConfigFileScenario.ConfigContent()
                {
                    X = newValue
                }, scenario.File);

                // Act
                var v = cfg.Get(c => c.X);

                // Assert
                v.Should().Be(originalValue);
            }
        }
Exemplo n.º 18
0
        public static bool UseTopDownRecommendedSettings()
        {
            bool useRecommendedSettings = false;

            //check with the user to update params
            if (Params.AskAboutTopDownParams)
            {
                var results = ProteaseSpecificMsgBox.Show("Use Top-Down Recommendations?",
                                                          "We recommend using the following parameters for top-down searches:\n" +
                                                          "\t-Uncheck 'Use Provided Precursor'\n" +
                                                          "\t-Use '60' for 'Deconvolution Max Assumed Charge State'\n" +
                                                          "\t-Uncheck 'Trim MS2 Peaks'\n" +
                                                          "\t-Uncheck all variable mods (Please use a GPTMD database instead)\n" +
                                                          "\t-SEARCH TASK ONLY: Check 'No Quantification'\n" +
                                                          "\t-SEARCH TASK ONLY: Check '1, 2, or 3 Missed Monoisotopic Peaks'\n" +
                                                          "\t-GPTMD TASK ONLY: Search for only acetylation, phosphorylation, and oxidation of M\n\n" +
                                                          "Would you like to use these recommended settings?");

                if (results.UseSettings)
                {
                    useRecommendedSettings = true;
                }
                //else do nothing

                //if they don't want to see this again, save the answer
                if (!results.AskAgain)
                {
                    Params.AskAboutTopDownParams = false;
                    Params.UseTopDownParams      = results.UseSettings;

                    Toml.WriteFile(Params, Path.Combine(GlobalVariables.DataDir, @"GUIsettings.toml"), MetaMorpheusTask.tomlConfig);
                }
            }
            else if (Params.UseTopDownParams) //user didn't want to check in, but wanted to update last time
            {
                useRecommendedSettings = true;
            }
            //else do nothing
            return(useRecommendedSettings);
        }
Exemplo n.º 19
0
        public void UseTransaction_ExternalChangesNotIncorporatedAndSavedBack()
        {
            using (var scenario = SingleConfigFileScenario.Setup(nameof(UseTransaction_ExternalChangesAreLoaded)))
            {
                // Arrange
                var          cfg       = scenario.CreateConfig();
                var          trans     = cfg.StartTransaction();
                const int    newXValue = 123;
                const string newYValue = "New Y";
                Toml.WriteFile(new SingleConfigFileScenario.ConfigContent()
                {
                    X = newXValue
                }, scenario.File);

                // Act
                cfg.Set(c => c.Y, newYValue);
                Action a = () => trans.Dispose();

                // Assert
                a.ShouldThrow <InvalidOperationException>().WithMessage("*externally*");
            }
        }
Exemplo n.º 20
0
        private async Task LoadModulesAsync()
        {
            Dictionary <string, bool> enabledModules = new Dictionary <string, bool>();

            if (File.Exists(Common.ModuleFile))
            {
                enabledModules = Toml.ReadFile <Dictionary <string, bool> >(Common.ModuleFile);
            }

            foreach (Type type in Assembly.GetEntryAssembly().GetExportedTypes()
                     .Where(x => typeof(ModuleBase).IsAssignableFrom(x) ||
                            x.IsSubclassOfRawGeneric(typeof(ModuleBase <>))))
            {
                if (enabledModules.TryAdd(type.Name, true) || enabledModules[type.Name])
                {
                    await _commandService.AddModuleAsync(type, _serviceProvider).ConfigureAwait(false);

                    _logger.LogInformation("Loaded {Module}", type.Name);
                }
            }

            Toml.WriteFile(enabledModules, Common.ModuleFile);
        }
Exemplo n.º 21
0
        private static void LoadConfig()
        {
            string configPath = Path.Combine(Paths.ConfigPath, "Config.toml");

            var tomlSettings = TomlSettings.Create(builder => builder
                                                   .ConfigureType <Version>(type => type
                                                                            .WithConversionFor <TomlString>(convert => convert
                                                                                                            .ToToml(tt => tt.ToString())
                                                                                                            .FromToml(ft => Version.Parse(ft.Value)))));

            var oldConfig = File.Exists(configPath) ? Toml.ReadFile <EnvironmentConfig>(configPath, tomlSettings) : null;

            var version = oldConfig?.Version ?? AmoebaEnvironment.Version;
            var cache   = oldConfig?.Cache ?? CreateDefaultCacheConfig();

            Toml.WriteFile(new EnvironmentConfig(AmoebaEnvironment.Version, cache), configPath, tomlSettings);
            Config = new EnvironmentConfig(version, cache);

            EnvironmentConfig.CacheConfig CreateDefaultCacheConfig()
            {
                return(new EnvironmentConfig.CacheConfig("../Config/Cache.blocks"));
            }
        }
Exemplo n.º 22
0
        private static void LoadConfig()
        {
            string configPath = Path.Combine(Paths.ConfigDirectoryPath, "Interface.toml");

            var tomlSettings = TomlSettings.Create(builder => builder
                                                   .ConfigureType <Version>(type => type
                                                                            .WithConversionFor <TomlString>(convert => convert
                                                                                                            .ToToml(tt => tt.ToString())
                                                                                                            .FromToml(ft => Version.Parse(ft.Value)))));

            var oldConfig = File.Exists(configPath) ? Toml.ReadFile <InterfaceConfig>(configPath, tomlSettings) : null;

            var version       = oldConfig?.Version ?? AmoebaEnvironment.Version;
            var communication = oldConfig?.Communication ?? CreateDefaultCommunicationConfig();

            Toml.WriteFile(new InterfaceConfig(AmoebaEnvironment.Version, communication), configPath, tomlSettings);
            Config = new InterfaceConfig(version, communication);

            InterfaceConfig.CommunicationConfig CreateDefaultCommunicationConfig()
            {
                return(new InterfaceConfig.CommunicationConfig("tcp:127.0.0.1:4040"));
            }
        }
Exemplo n.º 23
0
        public static void Init()
        {
            if (_default == null)
            {
                if (File.Exists(CONFIG_FILENAME))
                {
                    _default            = Toml.ReadFile <Config>(CONFIG_FILENAME);
                    _default.ConfigPath = CONFIG_FILENAME;
                }
                else
                {
                    var configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), CONFIG_FILENAME);

                    if (File.Exists(configPath))
                    {
                        _default            = Toml.ReadFile <Config>(configPath);
                        _default.ConfigPath = configPath;
                    }
                    else
                    {
                        _default = new Config();
                        Toml.WriteFile(_default, configPath);
                        _default.ConfigPath = configPath;

                        Console.WriteLine("A new config file has been created.");
                        Console.WriteLine("This program uses a TOML config file, any text editor should be able to edit it.");
                        Console.WriteLine("Open config file in default text editor? (y/n)");
                        if (Console.ReadLine() is "y" or "yes")
                        {
                            _default.ShellOpen();
                        }

                        Program.Exit();
                    }
                }
            }
        }
Exemplo n.º 24
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public string Save()
 {
     try
     {
         Toml.WriteFile(this, this.GetPath());
         return(string.Empty);
     }
     catch (FileNotFoundException fileNotFoundEx)
     {
         return(fileNotFoundEx.Message);
     }
     catch (UnauthorizedAccessException unauthAccessEx)
     {
         return(unauthAccessEx.Message);
     }
     catch (IOException ioEx)
     {
         return(ioEx.Message);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemplo n.º 25
0
        public static bool UseElastaseRecommendedSettings()
        {
            bool useRecommendedSettings = false;

            //check with the user to update params
            if (Params.AskAboutElastaseParams)
            {
                var results = ProteaseSpecificMsgBox.Show("Use Elastase Recommendations?",
                                                          "We recommend using the following parameters for elastase searches:\n" +
                                                          "\t-Check 'Semi-Specific Search' (Search Task Only)\n" +
                                                          "\t-Use '50' for the 'Max Peptide Len' (Search Task Only)\n" +
                                                          "\t-Use '16' for 'Max Missed Cleavages'.\n\n" +
                                                          "Would you like to use these recommended settings?");

                if (results.UseSettings)
                {
                    useRecommendedSettings = true;
                }
                //else do nothing

                //if they don't want to see this again, save the answer
                if (!results.AskAgain)
                {
                    Params.AskAboutElastaseParams = false;
                    Params.UseElastaseParams      = results.UseSettings;

                    Toml.WriteFile(Params, Path.Combine(GlobalVariables.DataDir, @"GUIsettings.toml"), MetaMorpheusTask.tomlConfig);
                }
            }
            else if (Params.UseElastaseParams) //user didn't want to check in, but wanted to update last time
            {
                useRecommendedSettings = true;
            }
            //else do nothing
            return(useRecommendedSettings);
        }
Exemplo n.º 26
0
        public static Configuration ReadConfig()
        {
            try
            {
                //If the file exists, just read it
                if (File.Exists(FileName))
                {
                    return(Toml.ReadFile <Configuration>(FileName));
                }

                //write the default config file
                Logger.Log("No config file detected, making one with default settings");
                Toml.WriteFile(new DefaultConfig(), FileName);

                return(Toml.ReadFile <Configuration>(FileName));
            }
            catch (Exception e)
            {
                Logger.LogError(e.Message);
                Logger.LogError("Error reading config file, maybe it's corrupted?");
            }

            return(new Configuration());
        }
Exemplo n.º 27
0
        private void InitConfig()
        {
            if (_tomlSettings == null)
            {
                _tomlSettings = TomlSettings.Create(cfg => cfg
                                                    .ConfigureType <SKColor>(type => type
                                                                             .WithConversionFor <TomlString>(conv => conv
                                                                                                             .FromToml(s => SKColor.Parse(s.Value))
                                                                                                             .ToToml(c => c.ToString()))));
            }

            try
            {
                _config = Toml.ReadFile <AppConfig>("config.toml", _tomlSettings);
                Console.WriteLine("Configuration loaded.");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Configuration not found. Using default configuration.");

                _config = new AppConfig();
                Toml.WriteFile(_config, "config.toml", _tomlSettings);
            }
        }
Exemplo n.º 28
0
            internal void Save()
            {
                UpdateExecutionInterval();

                _executionInterval.IfSome(ei =>
                {
                    if (ei != default)
                    {
                        var(ms, n)    = ei;
                        var tomlTable = Toml.Create();
                        tomlTable.Add(nameof(ms), ms);
                        tomlTable.Add(nameof(n), n);
                        var pathToExecutionInterval = Simulation.GetPrivatePath(new[] { nameof(SimData) }, EXECUTION_INTERVAL_FILE_NAME);
                        try
                        {
                            Toml.WriteFile(tomlTable, pathToExecutionInterval);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, $"{nameof(SimExecutionInterval)}.{nameof(Save)}");
                        }
                    }
                });
            }
Exemplo n.º 29
0
        public static void LoadMods()
        {
            TOML.ModList modList = new TOML.ModList();

            modList.Mods.Add(new TOML.Mod("TestMod", new Version(0, 0, 0)));

            Toml.WriteFile(modList, Application.persistentDataPath + "/ModList.tml");

            modList = Toml.ReadFile <TOML.ModList>(Application.persistentDataPath + "/ModList.tml");

            foreach (var mod in modList.Mods)
            {
                _modTOMLs.Add(mod);
                _loadMod(mod);
            }

            foreach (var modInstance in _modInstances)
            {
                modInstance.Value.PreInit();
            }

            foreach (var modInstance in _modInstances)
            {
                modInstance.Value.Init();
            }

            foreach (var modInstance in _modInstances)
            {
                modInstance.Value.PostInit();
            }

            foreach (var modInstance in _modInstances)
            {
                modInstance.Value.LoadContent();
            }
        }
Exemplo n.º 30
0
        /// <inheritdoc />
        public void SaveToFile()
        {
            if (_configFile == null)
            {
                Logger.Warning("[CFG] Cannot save the config file, because one was never loaded.");
                return;
            }

            try
            {
                var tblRoot = Toml.Create();

                foreach (var kvCVar in _configVars)
                {
                    var cVar = kvCVar.Value;
                    var name = kvCVar.Key;

                    var value = cVar.Value;
                    if (value == null && cVar.Registered)
                    {
                        value = cVar.DefaultValue;
                    }

                    if (value == null)
                    {
                        Logger.Error($"[CFG] CVar {name} has no value or default value, was the default value registered as null?");
                        continue;
                    }

                    var keyIndex = name.LastIndexOf(TABLE_DELIMITER);
                    var tblPath  = name.Substring(0, keyIndex).Split(TABLE_DELIMITER);
                    var keyName  = name.Substring(keyIndex + 1);

                    // locate the Table in the config tree
                    var table = tblRoot;
                    foreach (var curTblName in tblPath)
                    {
                        if (!table.TryGetValue(curTblName, out TomlObject tblObject))
                        {
                            tblObject = table.AddTable(curTblName);
                        }

                        table = tblObject as TomlTable ?? throw new InvalidConfigurationException($"[CFG] Object {curTblName} is being used like a table, but it is a {tblObject}. Are your CVar names formed properly?");
                    }

                    //runtime unboxing, either this or generic hell... ¯\_(ツ)_/¯
                    switch (value)
                    {
                    case Enum val:
                        table.AddValue(keyName, (int)(object)val);       // asserts Enum value != (ulong || long)
                        break;

                    case int val:
                        table.AddValue(keyName, val);
                        break;

                    case long val:
                        table.AddValue(keyName, val);
                        break;

                    case bool val:
                        table.AddValue(keyName, val);
                        break;

                    case string val:
                        table.AddValue(keyName, val);
                        break;

                    case float val:
                        table.AddValue(keyName, val);
                        break;

                    case double val:
                        table.AddValue(keyName, val);
                        break;

                    default:
                        Logger.Warning($"[CFG] Cannot serialize '{name}', unsupported type.");
                        break;
                    }
                }

                Toml.WriteFile(tblRoot, _configFile);
                Logger.Info($"[CFG] Server config saved to '{_configFile}'.");
            }
            catch (Exception e)
            {
                Logger.Warning($"[CFG] Cannot save the config file '{_configFile}'.\n {e.Message}");
            }
        }