public void Init() { if (!File.Exists(SettingFileName)) { Settings = GridServerSettings.Defaults; File.WriteAllText(SettingFileName, GridServerSettings.Serialize(Settings)); } else { try { Settings = GridServerSettings.Deserialize(File.ReadAllText(SettingFileName)); } catch (Exception e) { Settings = GridServerSettings.Defaults; Logger.Error($"Unable to read settings from '{SettingFileName}', loading defaults", e); } } _networkSystem.Init(); _networkSystem.StartListen(); }
public static string Serialize(GridServerSettings obj) { return(JsonConvert.SerializeObject(obj, Formatting.Indented)); }