private bool SaveInternal(Core.Config.Config configInstance, bool notify) { string configFile = CONFIGFILE_NAME; try { configFile = Path.Combine(this.envManager.Instance.AppFolder, CONFIGFILE_NAME); string contents = JsonConvert.SerializeObject(configInstance); File.WriteAllText(configFile, contents, CONFIGFILE_ENCODING); this.Instance = configInstance; if (notify) { NotifyChangedConfiguration(); } return(true); } catch (Exception ex) { log.Fatal($"Failed to load configuration from: {configFile}", ex); return(false); } }
private bool LoadInternal(bool notify) { string configFile = CONFIGFILE_NAME; try { configFile = Path.Combine(this.envManager.Instance.AppFolder, CONFIGFILE_NAME); string contents = File.ReadAllText(configFile, CONFIGFILE_ENCODING); this.Instance = JsonConvert.DeserializeObject <Core.Config.Config>(contents); if (notify) { NotifyChangedConfiguration(); } log.InfoFormat("Loaded configuration from '{0}', contains {1} waypoints", configFile, this.Instance?.RouterSettings?.Waypoints.Length ?? 0); return(true); } catch (Exception ex) { log.Fatal($"Failed to load configuration from: {configFile}", ex); return(false); } }
public bool Save(Core.Config.Config configInstance) { return(SaveInternal(configInstance, true)); }