diff --git a/src/MememntoPattern/IterativeEmployee/Caretaker.cs b/src/MememntoPattern/IterativeEmployee/Caretaker.cs
new file mode 100644
index 0000000..1e9254e
--- /dev/null
+++ b/src/MememntoPattern/IterativeEmployee/Caretaker.cs
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+
+namespace MememntoPattern.IterativeEmployee
+{
+ ///
+ /// Caretaker
+ ///
+ public class Caretaker
+ {
+ EmployeeMemento initialMememento;
+ List diffs;
+
+ public Caretaker()
+ {
+ diffs = new List();
+ initialMememento = null;
+ }
+
+ public void Save(Employee emp)
+ {
+ EmployeeMemento memento = emp.Save();
+
+ if (initialMememento == null)
+ initialMememento = memento;
+ else
+ diffs.Add(memento.GetDiffFor(GetLastSavedVersion()));
+ }
+
+ public void Revert(Employee emp)
+ {
+ EmployeeMemento em = GetLastSavedVersion();
+
+ if (diffs.Count > 0)
+ diffs.RemoveAt(diffs.Count - 1);
+
+ emp.Revert(em);
+ }
+
+ private EmployeeMemento GetLastSavedVersion()
+ {
+ var memento = initialMememento.Clone();
+ foreach (var diff in diffs)
+ {
+ memento.UpdateWithDelta(diff);
+ }
+
+ return memento;
+ }
+ }
+}
diff --git a/src/MememntoPattern/IterativeEmployee/Employee.cs b/src/MememntoPattern/IterativeEmployee/Employee.cs
new file mode 100644
index 0000000..14ea62c
--- /dev/null
+++ b/src/MememntoPattern/IterativeEmployee/Employee.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+
+namespace MememntoPattern.IterativeEmployee
+{
+ ///
+ /// Originator
+ ///
+ public class Employee
+ {
+ public string Name { get; set; }
+
+ public string Address { get; set; }
+
+ public List Phones { get; set; }
+
+ public EmployeeMemento Save()
+ {
+ return new EmployeeMemento(Name, Address);
+ }
+
+ public void Revert(EmployeeMemento memento)
+ {
+ Name = memento.Name;
+
+ Address = memento.Address;
+ }
+ }
+}
diff --git a/src/MememntoPattern/IterativeEmployee/EmployeeIterativeExample.cs b/src/MememntoPattern/IterativeEmployee/EmployeeIterativeExample.cs
new file mode 100644
index 0000000..ee76e98
--- /dev/null
+++ b/src/MememntoPattern/IterativeEmployee/EmployeeIterativeExample.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MememntoPattern.IterativeEmployee
+{
+ public class EmployeeIterativeExample
+ {
+ public void Run()
+ {
+ Caretaker caretaker = new Caretaker();
+ Employee e = new Employee();
+ e.Name = "Ghiuri";
+ e.Address = "Stairway to heaven";
+
+ Console.WriteLine("First saved address: {0}", e.Address);
+ caretaker.Save(e);
+
+ e.Address = "Highway to hell";
+
+ Console.WriteLine("Second saved address: {0}", e.Address);
+
+ caretaker.Save(e);
+
+ e.Address = "Home of the brave";
+
+ Console.WriteLine("Third saved address: {0}", e.Address);
+
+ caretaker.Save(e);
+
+ e.Address = "Somesing";
+
+ Console.WriteLine("Address before revert: {0}", e.Address);
+
+ caretaker.Revert(e);
+
+ Console.WriteLine("First reverted Address: {0}", e.Address);
+
+ caretaker.Revert(e);
+
+ Console.WriteLine("Second reverted Address: {0}", e.Address);
+
+ caretaker.Revert(e);
+
+ Console.WriteLine("Third reverted Address: {0}", e.Address);
+
+ caretaker.Revert(e);
+
+ Console.WriteLine("Forth reverted Address: {0}", e.Address);
+
+ }
+
+ }
+}
diff --git a/src/MememntoPattern/IterativeEmployee/EmployeeMemento.cs b/src/MememntoPattern/IterativeEmployee/EmployeeMemento.cs
new file mode 100644
index 0000000..cdacbc9
--- /dev/null
+++ b/src/MememntoPattern/IterativeEmployee/EmployeeMemento.cs
@@ -0,0 +1,51 @@
+namespace MememntoPattern.IterativeEmployee
+{
+ ///
+ /// Memento object
+ ///
+ public class EmployeeMemento : IIterativeMemento
+ {
+ public string Name { get; private set; }
+ public string Address { get; private set; }
+
+ public EmployeeMemento(string name, string address)
+ {
+ Name = name;
+ Address = address;
+ }
+
+ public EmployeeMementoDiff GetDiffFor(EmployeeMemento e)
+ {
+ EmployeeMementoDiff diff = new EmployeeMementoDiff();
+
+ if (Name != e.Name)
+ diff.UpdatedName = Name;
+
+ if (Address != e.Address)
+ diff.UpdatedAddress = Address;
+
+ return diff;
+ }
+
+ public void UpdateWithDelta(EmployeeMementoDiff diff)
+ {
+ if (diff.UpdatedName != null)
+ Name = diff.UpdatedName;
+
+ if (diff.UpdatedAddress != null)
+ Address = diff.UpdatedAddress;
+ }
+
+ public EmployeeMemento Clone()
+ {
+ return new EmployeeMemento(Name, Address);
+ }
+ }
+
+ public class EmployeeMementoDiff
+ {
+ public string UpdatedName { get; set; }
+
+ public string UpdatedAddress { get; set; }
+ }
+}
diff --git a/src/MememntoPattern/IterativeEmployee/IIterativeMemento.cs b/src/MememntoPattern/IterativeEmployee/IIterativeMemento.cs
new file mode 100644
index 0000000..98bff41
--- /dev/null
+++ b/src/MememntoPattern/IterativeEmployee/IIterativeMemento.cs
@@ -0,0 +1,9 @@
+namespace MememntoPattern.IterativeEmployee
+{
+ public interface IIterativeMemento
+ {
+ TMemento Clone();
+ TDiff GetDiffFor(TMemento e);
+ void UpdateWithDelta(TDiff diff);
+ }
+}
\ No newline at end of file
diff --git a/src/MememntoPattern/MementoPatternExamples.cs b/src/MememntoPattern/MementoPatternExamples.cs
index e912638..93f7b39 100644
--- a/src/MememntoPattern/MementoPatternExamples.cs
+++ b/src/MememntoPattern/MementoPatternExamples.cs
@@ -1,5 +1,6 @@
using MememntoPattern.Employee;
using MememntoPattern.EmployeeSerialized;
+using MememntoPattern.IterativeEmployee;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,6 +29,10 @@ namespace MememntoPattern
GoToNextStep();
+ EmployeeIterativeExample empIterEx = new EmployeeIterativeExample();
+ empIterEx.Run();
+ GoToNextStep();
+
Console.WriteLine(GetPitfalls());
}