示例#1
0
        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);
        }
示例#2
0
 public Persistence()
 {
     this.actuator         = new PeristenceActuator();
     this.context          = new PersistenceContext(actuator);
     this.context.Observer = ObserverConsole.Instance;
     this.context.EnterInitialState();
 }
示例#3
0
 public void Setup()
 {
     this.actuator = new PeristenceActuator();
 }