/// <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"); } }
/// <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(); } }
/// <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(); } }