public void YamlConfigTests_LoadSaveTest() { string path = Environment.CurrentDirectory + "\\TestConfig.yml"; YamlConfig conf = YamlConfig.Load(Environment.CurrentDirectory + "\\TestConfig.yml"); List <User> users = new List <User>(); try { users.Add(new User() { Name = "tom", Password = "******" }); users.Add(new User() { Name = "hiroki", Password = "******" }); conf.Root.Add("key", "value"); conf.Root.Add("int", 10000); conf.Root.Add("users", users); conf.Save(); } catch { } }
public static CrashReport ExportReport(string title, Exception cause, bool debugReport = false) { DateTime time = DateTime.Now; string path = Server.ExecutePath + "/reports/crash"; string file = path + "/report-" + time.ToString("yyyy_M_d H_mm_ss") + ".report"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } YamlConfig report = YamlConfig.Load(file); CrashReport data = null; if (debugReport) { data = new CrashReport(title, cause, time); } else { data = new CrashReport(title, cause.ToString(), time); } report.Set("reportData", data); report.Save(); return(data); }
public void Run() { do { Console.WriteLine("This program is free software: you can redistribute it and/or modify"); Console.WriteLine("it under the terms of the GNU General Public License as published by"); Console.WriteLine("the Free Software Foundation, either version 3 of the License, or"); Console.WriteLine("(at your option) any later version."); Console.WriteLine(""); Console.WriteLine("This program is distributed in the hope that it will be useful,"); Console.WriteLine("but WITHOUT ANY WARRANTY; without even the implied warranty of"); Console.WriteLine("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"); Console.WriteLine("GNU General Public License for more details."); Console.WriteLine(""); Console.WriteLine("You should have received a copy of the GNU General Public License"); Console.WriteLine("along with this program. If not, see <http://www.gnu.org/licenses/>."); if (GetInput("Accept the license of use?", "n", "y/N") == "y") { licence = true; } }while (licence == false); do { port = Convert.ToInt32(GetInput("Insert the port on which the server will run", Convert.ToString(DEFAULT_PORT))); }while (port == -1); do { players = Convert.ToInt32(GetInput("Insert the maximum number of players", Convert.ToString(DEFAULT_PLAYERS))); }while (players == -1); do { motd = GetInput("Insert the server name", DEFAULT_MOTD); }while (motd == "null"); YamlConfig config = new YamlConfig(route + "server.yml"); config.Set("motd", motd); config.Set("ip", "0.0.0.0"); config.Set("port", port); config.Set("max-players", players); config.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Configuration finished! Starting server, one moment please..."); Console.ResetColor(); }