private static void StartPlacingOrders(int numberOfOrders, Waitress waitress, Dictionary <string, DateTime> startTimes) { for (var i = 0; i < numberOfOrders; i++) { var orderId = PlaceNewOrder(waitress, i); startTimes.Add(orderId, DateTime.Now); Thread.Sleep(100); } }
private static string PlaceNewOrder(Waitress waitress, int i) { var orderId = waitress.PlaceOrder(i, i%2 == 0 ? "good looking" : "dodgy", new[] { new Item("Sushi", 2), new Item("Clean glass", 2), new Item("Sake", 2), }); return orderId; }
private static string PlaceNewOrder(Waitress waitress, int i) { var orderId = waitress.PlaceOrder(i, i % 2 == 0 ? "good looking" : "dodgy", new[] { new Item("Sushi", 2), new Item("Clean glass", 2), new Item("Sake", 2), }); return(orderId); }
static void Main() { #warning TODO: Replace topics with message types??? #warning TODO: Make TimeToLiveHandler work with OrderMessageBase var waitress = new Waitress("Sexy Mary"); var kitchen = PrepareKitchen(); var assistantManager = PrepareAssistantManager(); var cashier = new Cashier(); var threadedCashier = PrepareThreadedCashier(cashier); var alarmClock = PrepareAlarmClock(); var midgetHouse = new MidgetHouse(); TopicPubSub.Instance.Subscribe <OrderPlaced>(Topics.NewOrders, midgetHouse); TopicPubSub.Instance.Subscribe(Topics.CooksQueue, kitchen); TopicPubSub.Instance.Subscribe(Topics.Pricing, assistantManager); TopicPubSub.Instance.Subscribe(Topics.Payment, threadedCashier); TopicPubSub.Instance.Subscribe <OrderCompleted>(Topics.CompletedOrders, midgetHouse); TopicPubSub.Instance.Subscribe(Topics.WakeUpCalls, alarmClock); Start(); const int numberOfOrders = 200; var startTimes = new Dictionary <string, DateTime>(); StartPlacingOrders(numberOfOrders, waitress, startTimes); var summary = PayOrders(cashier, startTimes, numberOfOrders); Thread.Sleep(1000); Console.WriteLine(summary.ToString()); Console.WriteLine("Press enter to finish..."); Console.ReadLine(); }
static void Main() { #warning TODO: Replace topics with message types??? #warning TODO: Make TimeToLiveHandler work with OrderMessageBase var waitress = new Waitress("Sexy Mary"); var kitchen = PrepareKitchen(); var assistantManager = PrepareAssistantManager(); var cashier = new Cashier(); var threadedCashier = PrepareThreadedCashier(cashier); var alarmClock = PrepareAlarmClock(); var midgetHouse = new MidgetHouse(); TopicPubSub.Instance.Subscribe<OrderPlaced>(Topics.NewOrders, midgetHouse); TopicPubSub.Instance.Subscribe(Topics.CooksQueue, kitchen); TopicPubSub.Instance.Subscribe(Topics.Pricing, assistantManager); TopicPubSub.Instance.Subscribe(Topics.Payment, threadedCashier); TopicPubSub.Instance.Subscribe<OrderCompleted>(Topics.CompletedOrders, midgetHouse); TopicPubSub.Instance.Subscribe(Topics.WakeUpCalls, alarmClock); Start(); const int numberOfOrders = 200; var startTimes = new Dictionary<string, DateTime>(); StartPlacingOrders(numberOfOrders, waitress, startTimes); var summary = PayOrders(cashier, startTimes, numberOfOrders); Thread.Sleep(1000); Console.WriteLine(summary.ToString()); Console.WriteLine("Press enter to finish..."); Console.ReadLine(); }
private static void StartPlacingOrders(int numberOfOrders, Waitress waitress, Dictionary<string, DateTime> startTimes) { for (var i = 0; i < numberOfOrders; i++) { var orderId = PlaceNewOrder(waitress, i); startTimes.Add(orderId, DateTime.Now); Thread.Sleep(100); } }