Example #1
0
 public static void StoreConfig(string username, string token, string machineID)
 {
     var newConfig = new LifeguardConfiguration { Username = username, Token = token, MachineID = machineID };
     string jsonConfig = JsonConvert.SerializeObject(newConfig);
     var file = GetFile();
     File.WriteAllText(file.FullName, jsonConfig);
 }
Example #2
0
 private static void LoadConfig()
 {
     var file = GetFile();
     if (file.Exists)
     {
         string contents = File.ReadAllText(file.FullName);
         try
         {
             //TODO: decrypt the encrypted stuff
             config = JsonConvert.DeserializeObject<LifeguardConfiguration>(contents);
         }
         catch (JsonException je) {
             //config got corrupted somehow, create a new blank one
             config = new LifeguardConfiguration();
         }
     }
 }