Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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);
        }