using System; using System.Collections.Generic; namespace Clock { [Serializable] public class EventFile { public List eventList = new List(); private const string _fileName = "events.json"; public void AddEvent(float timestamp, string name) { eventList.Add(new TimeEvent((float)Math.Truncate(timestamp), name)); eventList.Sort(SortTimestamp); Save(); } private void Save() { OWClock.Helper.Storage.Save(this, _fileName); } public static EventFile LoadSaveFile() { var save = OWClock.Helper.Storage.Load(_fileName); save.eventList.Sort(SortTimestamp); return save ?? new EventFile(); } private static int SortTimestamp(TimeEvent e1, TimeEvent e2) { return e1.Timestamp.CompareTo(e2.Timestamp); } } }