예제 #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;
        }
예제 #2
0
파일: RevDb.cs 프로젝트: rayschpp/lebot
        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);
        }
예제 #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;
        }
예제 #4
0
파일: RevDb.cs 프로젝트: rayschpp/lebot
        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);
        }