Esempio n. 1
0
 public static LocalSettings LoadSettingsFile()
 {
     try
     {
         string settings = EncodedFile.Read(Constants.SettingsFileName);
         return(JsonConvert.DeserializeObject <LocalSettings>(settings));
     }
     catch (Exception ex) when(ex is DirectoryNotFoundException || ex is FileNotFoundException)
     {
         return(new LocalSettings());
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException($"Failed to load the arsub settings file, may be corrupted", ex);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Saves the settings in the settings files
        /// </summary>
        /// <param name="logger"></param>
        /// <returns></returns>
        public int SaveSettingsFile(ILogger logger)
        {
            string settings = JsonConvert.SerializeObject(this);

            return(EncodedFile.Create(Constants.SettingsFileName, settings, logger));
        }