public void Execute() { var solver = ConstraintSolver.Instance; state = solver.CreateMemento(); target.Move(delta); solver.Solve(); }
public void Execute() { ConstraintSolver solver = ConstraintSolver.Instance(); this.state = solver.CreateMemento(); // create a memento this.target.Move(this.delta); solver.Solve(); }
public object CreateMemento() { ConstraintSolverMemento memento = new ConstraintSolverMemento(); // Save state here memento.StateItem1 = StateItem1; memento.StateItem2 = StateItem2; memento._stateList = new List <string>(_stateList); return(memento); }
public void SetMemento(object memento) { if (memento.GetType() == typeof(ConstraintSolverMemento)) { Console.WriteLine("\nRestoring old state ...\n"); ConstraintSolverMemento oldState = (ConstraintSolverMemento)memento; // Restore state here ... StateItem1 = oldState.StateItem1; StateItem2 = oldState.StateItem2; _stateList = oldState._stateList; } else { Console.WriteLine("\nHa! Nice try! That object was not a proper memento!\n"); } }
public void SetMemento(ConstraintSolverMemento constraintSolverMemento) { // Some implementation }
public void SetMemento(ConstraintSolverMemento memento) { }