Пример #1
0
        private static void SaveDB()
        {
            while (dbLock)
            {
            }

            dbLock = true;
            string json       = JsonConvert.SerializeObject(db, Formatting.None);
            var    compressed = ExtenderGzip.Compress(json);

            File.WriteAllBytes(config.dbFile, compressed);
            dbLock = false;
        }
Пример #2
0
        static Extender()
        {
            config = new Config();

            if (File.Exists(config.dbFile))
            {
                var    compressed = File.ReadAllBytes(config.dbFile);
                string json       = ExtenderGzip.Decompress(compressed);
                db = JsonConvert.DeserializeObject <Dictionary <int, ExtendedEntry> >(json);
            }
            else
            {
                db = new Dictionary <int, ExtendedEntry>();
            }

            new Thread(new ThreadStart(ScheduledSave)).Start();
        }