private int getServerPort() { string settingTitle = "ServerPort"; int defaultValue = 7876; if (serverSettings.CheckSetting(settingTitle)) { return(int.Parse(serverSettings.ReadSetting(settingTitle))); } else { serverSettings.EditSetting(settingTitle, defaultValue.ToString()); return(defaultValue); } }
public static void InstanceMethod() { MSMCore msm = new MSMCore(); msm.SettingsDirectory = Environment.CurrentDirectory; while (true) { string consoleRead = Console.ReadLine(); string[] consoleArgs = consoleRead.Split(' '); consoleArgs[0] = consoleArgs[0].ToUpper(); if (consoleArgs[0] == "SAVESETTINGS") { msm.SaveSettings(); } if (consoleArgs[0] == "EDITSETTING") { msm.EditSetting(consoleArgs[1], consoleArgs[2]); } if (consoleArgs[0] == "DELETESETTING") { msm.DeleteSetting(consoleArgs[1]); } if (consoleArgs[0] == "READSETTING") { Console.WriteLine("Returned value : " + msm.ReadSetting(consoleArgs[1])); } if (consoleArgs[0] == "CHECKSETTING") { Console.WriteLine("Returned Value : " + msm.CheckSetting(consoleArgs[1])); } if (consoleArgs[0] == "HELP") { Console.WriteLine("Showing help - Help displays all of the public methods in MSM"); Console.WriteLine("There are currently 5 commands. All of these commands you can use in your project code"); Console.WriteLine(" "); Console.WriteLine("EditSetting [SettingTitle] [SettingValue] - Edits a setting in the settings array."); Console.WriteLine("ReadSetting [SettingTitle] - Returns the value in that setting."); Console.WriteLine("CheckSetting [SettingTitle] - Returns a bool value if the setting exists or not."); Console.WriteLine("DeleteSetting [SettingTitle] - Deletes that setting from the settings array."); Console.WriteLine("SaveSettings [SettingTitle] - Saves the settings array to a file."); } } }