public static bool SaveDatabase(RevDb db, string name) { JsonSerializer ser = new JsonSerializer(); ser.PreserveReferencesHandling = PreserveReferencesHandling.None; Directory.CreateDirectory("output/RevisionData/"); using (StreamWriter sw = new StreamWriter(name)) using (JsonWriter wr = new JsonTextWriter(sw)) { ser.Serialize(wr, db); } return true; }
public static bool SaveDatabase(RevDb db, string name) { JsonSerializer ser = new JsonSerializer(); ser.PreserveReferencesHandling = PreserveReferencesHandling.None; Directory.CreateDirectory("output/RevisionData/"); using (StreamWriter sw = new StreamWriter(name)) using (JsonWriter wr = new JsonTextWriter(sw)) { ser.Serialize(wr, db); } return(true); }
public static RevDb LoadDatabase(string name) { if (!File.Exists(name)) { RevDb rdb = new RevDb(); RevDb.SaveDatabase(rdb, name); } RevDb db; JsonSerializer ser = new JsonSerializer(); using (StreamReader r = new StreamReader(name)) using (JsonTextReader reader = new JsonTextReader(r)) { db = ser.Deserialize<RevDb>(reader); } return db; }
public static RevDb LoadDatabase(string name) { if (!File.Exists(name)) { RevDb rdb = new RevDb(); RevDb.SaveDatabase(rdb, name); } RevDb db; JsonSerializer ser = new JsonSerializer(); using (StreamReader r = new StreamReader(name)) using (JsonTextReader reader = new JsonTextReader(r)) { db = ser.Deserialize <RevDb>(reader); } return(db); }