Add basic memento pattern
This commit is contained in:
30
src/MememntoPattern/Employee/Employee.cs
Normal file
30
src/MememntoPattern/Employee/Employee.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MememntoPattern.Employee
|
||||
{
|
||||
/// <summary>
|
||||
/// Originator
|
||||
/// </summary>
|
||||
public class Employee
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public List<String> Phones { get; set; }
|
||||
|
||||
public EmployeeMemento Save()
|
||||
{
|
||||
return new EmployeeMemento(Name, Address);
|
||||
}
|
||||
|
||||
public void Revert(EmployeeMemento memento)
|
||||
{
|
||||
Name = memento.Name;
|
||||
Address = memento.Address;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user