示例#1
0
        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);
            }
        }
示例#2
0
 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;
 }
示例#3
0
        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);
        }
示例#4
0
        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();
        }
示例#5
0
        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();
        }
示例#6
0
        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);
            }
        }