static void Main(string[] args) { string fileName = "statemachine.dat"; { PeristenceActuator actuator = new PeristenceActuator(); PersistenceContext context = new PersistenceContext(actuator); context.EvOn(); Console.WriteLine(context.StateCurrent.Name); using (StreamWriter streamWriter = File.CreateText(fileName)) { context.Serialize(streamWriter); } } { PeristenceActuator actuator = new PeristenceActuator(); PersistenceContext context = new PersistenceContext(actuator); using (StreamReader streamReader = new StreamReader(fileName)) { context.DeSerialize(streamReader); } Console.WriteLine(context.StateCurrent.Name); } Environment.Exit(0); }
public Persistence() { this.actuator = new PeristenceActuator(); this.context = new PersistenceContext(actuator); this.context.Observer = ObserverConsole.Instance; this.context.EnterInitialState(); }
public void Setup() { this.actuator = new PeristenceActuator(); }