static void Main(string[] args) { Console.WriteLine("Hello State Pattern!"); // OrderTest(); StateMachine <LampState, LampTrigger> machine = LampStrategyFactory.Create("A"); ProxyLamp lamp = new ProxyLamp(machine); Console.WriteLine(lamp.Graph); Console.WriteLine(lamp.State); lamp.Push(); Console.WriteLine(lamp.State); //lamp.Push(); //Console.WriteLine(lamp.State); //lamp.Photo(); //Console.WriteLine(lamp.State); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(6)); Console.WriteLine(lamp.State); }
static void Main(string[] args) { Console.WriteLine("Hello State Pattern!"); // OrderTest(); IMessageService messageService = new ConsoleMessageService(); ProxyLamp lamp = new ProxyLamp(new LampStateMachine(messageService)); // lamp.TimeLimit = TimeSpan.Parse("13:00"); Console.WriteLine(lamp.Graph); Console.WriteLine(lamp.State); lamp.PushUp(); Console.WriteLine(lamp.State); Console.ReadKey(); lamp.PushDown(); Console.WriteLine(lamp.State); lamp.PushUp(); Console.WriteLine(lamp.State); lamp.PushUp(); Console.WriteLine(lamp.State); lamp.PushUp(); Console.WriteLine(lamp.State); lamp.PushDown(); Console.WriteLine(lamp.State); }