Exemple #1
0
        public void Revert(Employee emp)
        {
            EmployeeMemento em = GetLastSavedVersion();

            if (diffs.Count > 0)
            {
                diffs.RemoveAt(diffs.Count - 1);
            }

            emp.Revert(em);
        }
Exemple #2
0
        public void Save(Employee emp)
        {
            EmployeeMemento memento = emp.Save();

            if (initialMememento == null)
            {
                initialMememento = memento;
            }
            else
            {
                diffs.Add(memento.GetDiffFor(GetLastSavedVersion()));
            }
        }
Exemple #3
0
 public Caretaker()
 {
     diffs            = new List <EmployeeMementoDiff>();
     initialMememento = null;
 }
Exemple #4
0
        public void Revert(EmployeeMemento memento)
        {
            Name = memento.Name;

            Address = memento.Address;
        }