public AppSettingsFile(string filePath)
 {
     _filePath = filePath;
     try
     {
         var content     = FileSystemHelpers.ReadAllTextFromFile(Path.Combine(Environment.CurrentDirectory, AppSettingsFileName));
         var appSettings = JsonConvert.DeserializeObject <AppSettingsFile>(content);
         IsEncrypted       = appSettings.IsEncrypted;
         Values            = appSettings.Values;
         ConnectionStrings = appSettings.ConnectionStrings;
     }
     catch
     {
         Values            = new Dictionary <string, string>();
         ConnectionStrings = new Dictionary <string, string>();
         IsEncrypted       = true;
     }
 }
Example #2
0
 public AppSettingsFile(string filePath)
 {
     _filePath = filePath;
     try
     {
         var content     = FileSystemHelpers.ReadAllTextFromFile(_filePath);
         var appSettings = JsonConvert.DeserializeObject <AppSettingsFile>(content);
         IsEncrypted       = appSettings.IsEncrypted;
         Values            = appSettings.Values;
         ConnectionStrings = appSettings.ConnectionStrings;
         Host = appSettings.Host;
     }
     catch
     {
         Values            = new Dictionary <string, string>();
         ConnectionStrings = new Dictionary <string, string>();
         IsEncrypted       = true;
     }
 }
Example #3
0
 public ProxyFile(string filePath)
 {
     _filePath = filePath;
     if (File.Exists(_filePath))
     {
         try
         {
             var content     = FileSystemHelpers.ReadAllTextFromFile(_filePath);
             var proxyConfig = JsonConvert.DeserializeObject <ProxyConfig>(content);
             Proxies = proxyConfig.ProxyMap;
         }
         catch
         {
             // throw the exception if the underlying proxies.json file has become invalid
             ColoredConsole.WriteLine($"Exception while reading proxy file {_filePath}.");
             throw;
         }
     }
 }