Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public bool Save(Core.Config.Config configInstance)
 {
     return(SaveInternal(configInstance, true));
 }