public MementoPersonalInfo this[string UndoesOrRedoes] { get { switch (UndoesOrRedoes) { case "Undo": Redos.Push(Undos.Last.Value); MementoPersonalInfo state = Undos.Last.Value; Undos.RemoveLast(); Capacity = Undos.Count; RedoesQuantity = Redos.Count; return(state); case "Redo": Undos.AddLast(Redos.Pop()); Capacity = Undos.Count; RedoesQuantity = Redos.Count; return(Undos.Last.Value); default: Capacity = Undos.Count; RedoesQuantity = Redos.Count; return(null); } } }
public void SetMemento(MementoPersonalInfo memento) { Name = memento.Name; Surname = memento.Surname; PhoneNumber = memento.PhoneNumber; Address = memento.Address; Email = memento.Email; }
public void Add(MementoPersonalInfo memento) { if (Undos.Count < 256) { Undos.AddLast(memento); } else { Undos.RemoveFirst(); Undos.AddLast(memento); } Capacity = Undos.Count; RedoesQuantity = Redos.Count; }