示例#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);
        }