Ejemplo n.º 1
0
        public void TestEverything()
        {
            var innerDispatcher = new MessageDispatcher();
            var dispatcher      = new LoggingMessageDispatcher(innerDispatcher);
            var orderRepo       = new OrderRepository();

            var entryPoint = new AppEntryPoint(dispatcher);
            var order      = new Order {
                TicketCount = 4, Subtotal = 100M
            };
            var orderProcessor = new OrderProcessor(dispatcher);
            var ticketManager  = new TicketManager(dispatcher, orderRepo, 500);
            var feeManager     = new BasicFeeManager(dispatcher);
            var taxManager     = new TaxManager(dispatcher);
            var paymentManager = new PaymentManager(dispatcher);
            var storageManager = new StorageManager(dispatcher, orderRepo);

            dispatcher.Subscribe <OrderPlaced>(orderProcessor);
            dispatcher.Subscribe <TicketsReserved>(orderProcessor);
            dispatcher.Subscribe <FeesCalculated>(orderProcessor);
            dispatcher.Subscribe <TaxesCalculated>(orderProcessor);
            dispatcher.Subscribe <CreditCardCharged>(orderProcessor);
            dispatcher.Subscribe(ticketManager);
            dispatcher.Subscribe(feeManager);
            dispatcher.Subscribe(taxManager);
            dispatcher.Subscribe(paymentManager);
            dispatcher.Subscribe(storageManager);

            entryPoint.TakeOrder(4, 50M, "1234-1234-1234-1223");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var orderRepo       = new OrderRepository();
            var innerDispatcher = new MessageDispatcher();
            var dispatcher      = new LoggingMessageDispatcher(innerDispatcher);

            var entryPoint     = new AppEntryPoint(dispatcher);
            var orderProcessor = new OrderProcessor(dispatcher);
            var ticketManager  = new TicketManager(dispatcher, orderRepo, 500);
            var feeManager     = new BasicFeeManager(dispatcher);
            var taxManager     = new TaxManager(dispatcher);
            var paymentManager = new PaymentManager(dispatcher);
            var storageManager = new StorageManager(dispatcher, orderRepo);

            dispatcher.Subscribe <OrderPlaced>(orderProcessor);
            dispatcher.Subscribe <TicketsReserved>(orderProcessor);
            dispatcher.Subscribe <FeesCalculated>(orderProcessor);
            dispatcher.Subscribe <TaxesCalculated>(orderProcessor);
            dispatcher.Subscribe <CreditCardCharged>(orderProcessor);

            dispatcher.Subscribe(ticketManager);
            dispatcher.Subscribe(feeManager);
            dispatcher.Subscribe(taxManager);
            dispatcher.Subscribe(paymentManager);
            dispatcher.Subscribe(storageManager);
            dispatcher.Subscribe(entryPoint);

            entryPoint.TakeOrder(4, 50M, "1234-1234-1234-1223");

            System.Console.ReadKey();
        }