using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using Newtonsoft.Json; namespace OrgSyncDGui { class History { public Dictionary history; private string jsonFilePath; public History(string jsonFilePath) { this.history = new Dictionary(); this.jsonFilePath=jsonFilePath; } public void load() { if (!File.Exists(this.jsonFilePath)) { return; } using (StreamReader reader = new StreamReader(this.jsonFilePath)) { string jsonStr = reader.ReadToEnd(); this.history=JsonConvert.DeserializeObject>(jsonStr); } } public void save() { string jsonStr = JsonConvert.SerializeObject(this.history,Formatting.Indented); using (StreamWriter writer = new StreamWriter(this.jsonFilePath)) { writer.Write(jsonStr); } } } }