Exemplo n.º 1
0
 /// <summary>
 /// Clear the Cached State and delete the corresponding file if it exists.
 /// </summary>
 public void ClearState()
 {
     State = new CachedState();
     if (File.Exists("state.json"))
     {
         File.Delete("state.json");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Load the Cached State from a file, or create a new one.
 /// </summary>
 public void LoadState()
 {
     if (File.Exists("state.json"))
     {
         string stateJson = File.ReadAllText("state.json");
         State = JsonConvert.DeserializeObject <CachedState>(stateJson);
     }
     else
     {
         State = new CachedState();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Load the Cached State from a file, or create a new one.
 /// </summary>
 public void LoadState()
 {
     if (File.Exists("state.json"))
     {
         string stateJson = File.ReadAllText("state.json");
         State = JsonConvert.DeserializeObject <CachedState>(stateJson);
         if (State.Fingerprint == Guid.Empty)
         {
             State.Fingerprint = Guid.NewGuid();
             SaveState();
         }
     }
     else
     {
         State = new CachedState();
     }
 }