44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace OrgSyncDGui
|
|
{
|
|
class History
|
|
{
|
|
public Dictionary<string,string> history;
|
|
private string jsonFilePath;
|
|
public History(string jsonFilePath)
|
|
{
|
|
this.history = new Dictionary<string, string>();
|
|
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<Dictionary<string, string>>(jsonStr);
|
|
}
|
|
}
|
|
|
|
public void save()
|
|
{
|
|
string jsonStr = JsonConvert.SerializeObject(this.history,Formatting.Indented);
|
|
using (StreamWriter writer = new StreamWriter(this.jsonFilePath))
|
|
{
|
|
writer.Write(jsonStr);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|