public void Save(Piece[] pieces, Ticket[] tickets, Session session) { SessionContent content = new SessionContent(tickets, pieces); string jcontent = JsonConvert.SerializeObject(content, Formatting.Indented); File.WriteAllText(string.Format(".\\saves\\{0}.json", session.Name), jcontent); }
public ApplicationLayer Load(Session session) { string jcontent = File.ReadAllText(string.Format(".\\saves\\{0}.json", session.Name)); SessionContent content = JsonConvert.DeserializeObject <SessionContent>(jcontent); ApplicationLayer app = new ApplicationLayer(content.tickets, content.pieces); Ticket[] closed = app.FilterTicketsBy((t) => t.Closed); if (closed != null) { foreach (Ticket ticket in closed) { ticket.CalculateDuration(); //recalculate Durations } } return(app); }