director/Scratch.cs

37 lines
961 B
C#
Raw Normal View History

2021-08-18 23:16:57 -04:00
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using schedulable;
2021-08-18 23:16:57 -04:00
namespace director
{
public class Scratch
{
private const string path = "scratch.json";
public List<schedulable.Scheduled> agenda { get; set; } = new List<schedulable.Scheduled>();
2021-08-18 23:16:57 -04:00
public Dictionary<string, string> Calendars { get; set; } = new Dictionary<string, string>();
//calendar ICSs
public static Scratch LoadScratch()
{
if (File.Exists(path))
{
return JsonConvert.DeserializeObject<Scratch>(File.ReadAllText(path));
}
else
{
var toReturn = new Scratch();
toReturn.Save();
return toReturn;
}
}
public void Save()
{
File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented));
}
}
}