Пример #1
0
        public void CancelSnooze()
        {
            SnoozeData sd = new SnoozeData()
            {
                SnoozeUntil = null
            };

            Save(sd);
        }
Пример #2
0
        public void Snooze(int minutes)
        {
            var su = DateTime.Now.AddMinutes(minutes);

            SnoozeData sd = new SnoozeData()
            {
                SnoozeUntil = su
            };

            Save(sd);
        }
Пример #3
0
 private void Save(SnoozeData data)
 {
     lock (_lock)
     {
         using (StreamWriter file = System.IO.File.CreateText(RepositoryFile))
         {
             JsonSerializer serializer = new JsonSerializer();
             serializer.Formatting = Formatting.Indented;
             serializer.Serialize(file, data);
         }
     }
 }
Пример #4
0
        private SnoozeData Load()
        {
            lock (_lock)
            {
                SnoozeData shd = null;

                if (File.Exists(RepositoryFile) == false)
                {
                    shd = new SnoozeData();
                }
                else
                {
                    using (StreamReader file = System.IO.File.OpenText(RepositoryFile))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        shd = (SnoozeData)serializer.Deserialize(file, typeof(SnoozeData));
                    }
                }

                return(shd);
            }
        }