Beispiel #1
0
 public void RegisterEventSubscriber <TEvent>(ISubscribeToEvents <TEvent> subscriber) where TEvent : IEvent
 {
     if (!_eventSubscribers.ContainsKey(typeof(TEvent)))
     {
         _eventSubscribers.Add(typeof(TEvent), new List <Action <IEvent> >());
     }
     _eventSubscribers[typeof(TEvent)].Add(e => subscriber.Handle((TEvent)e));
 }
        public HotelsAndRoomsAdapter(string integrationFilesDirectoryPath, ISubscribeToEvents eventsSubscriber)
        {
            this.IntegrationFilesDirectoryPath = integrationFilesDirectoryPath;
            this.repository = new HotelsAndRoomsRepository();

            this.eventsSubscriber = eventsSubscriber;
            this.eventsSubscriber.RegisterHandler <RoomBooked>(this.Handle);
            // TODO: question: should we 'functionally subscribe' within the domain code instead?
            // TODO: handle the unsubscription
        }
Beispiel #3
0
        public PizzeriasYPizzasAdapter(string integrationFilesDirectoryPath, ISubscribeToEvents eventsSubscriber)
        {
            this.IntegrationFilesDirectoryPath = integrationFilesDirectoryPath;
            this.repository = new PizzeriasYPizzasRepository();

            this.eventsSubscriber = eventsSubscriber;
            this.eventsSubscriber.RegisterHandler <PizzaEnviada>(this.Handle);
            // TODO: question: should we 'functionally subscribe' within the domain code instead?
            // TODO: handle the unsubscription
        }
Beispiel #4
0
 /// <summary>
 /// Instantiates a <see cref="ReadModelFacade"/>.
 /// </summary>
 /// <param name="roomsProvider"></param>
 /// <param name="hotelProvider"></param>
 /// <param name="reservationsProvider"></param>
 /// <param name="bus"></param>
 public ReadModelFacade(IProvideRooms roomsProvider, IProvideHotel hotelProvider, IProvideReservations reservationsProvider, ISubscribeToEvents bus)
 {
     this.roomsProvider        = roomsProvider;
     this.hotelProvider        = hotelProvider;
     this.reservationsProvider = reservationsProvider;
 }
Beispiel #5
0
 /// <summary>
 /// Subscribe the "command handler" to per-type command publication on the eventPublisher.
 /// </summary>
 /// <param name="writeModelFacade">The callback/handler provider.</param>
 /// <param name="bus">The eventPublisher to subscribe on.</param>
 private static void SubscribeCommands(WriteModelFacade writeModelFacade, ISubscribeToEvents bus)
 {
     bus.RegisterHandler <PedidoCommand>(writeModelFacade.Handle);
 }
Beispiel #6
0
        public static WriteModelFacade BuildTheWriteModelHexagon(IPedidoRepository grabarPedido, IClienteRepository manejarClientes, IPublishEvents eventPublisher, ISubscribeToEvents eventSubscriber)
        {
            var writeModelCommandHandler = new WriteModelFacade(new AlmacenarPedido(grabarPedido, manejarClientes, eventPublisher));

            CompositionRootHelper.SubscribeCommands(writeModelCommandHandler, eventSubscriber);

            return(writeModelCommandHandler);
        }
Beispiel #7
0
        public static ReadModelFacade BuildTheReadModelHexagon(IProveerPizzas pizzasAdapter, IProveerPizzeria pizzeriaAdapter, IProveerPedido pedidoAdapter = null, ISubscribeToEvents bus = null)
        {
            if (bus == null)
            {
                bus = new FakeBus();
            }

            if (pedidoAdapter == null)
            {
                pedidoAdapter = new ReservaAdapter(bus);
            }

            return(new ReadModelFacade(pizzasAdapter, pizzeriaAdapter, pedidoAdapter, bus));
        }
Beispiel #8
0
 /// <summary>
 /// Subscribe the "command handler" to per-type command publication on the eventPublisher.
 /// </summary>
 /// <param name="writeModelFacade">The callback/handler provider.</param>
 /// <param name="bus">The eventPublisher to subscribe on.</param>
 private static void SubscribeCommands(WriteModelFacade writeModelFacade, ISubscribeToEvents bus)
 {
     bus.RegisterHandler <PedidoCommand>(writeModelFacade.Handle);
     bus.RegisterHandler <CancelarPedidoCommand>(writeModelFacade.Handle); // the line to be added
 }
        public static WriteModelFacade BuildTheWriteModelHexagon(ISaveBooking saveBooking, IHandleClients handleClients, IPublishEvents eventPublisher, ISubscribeToEvents eventSubscriber)
        {
            var writeModelCommandHandler = new WriteModelFacade(new BookingStore(saveBooking, handleClients, eventPublisher));

            CompositionRootHelper.SubscribeCommands(writeModelCommandHandler, eventSubscriber);

            return(writeModelCommandHandler);
        }
        public static ReadModelFacade BuildTheReadModelHexagon(IProvideRooms roomsAdapter, IProvideHotel hotelAdapter, IProvideReservations reservationAdapter = null, ISubscribeToEvents bus = null)
        {
            if (bus == null)
            {
                bus = new FakeBus();
            }

            if (reservationAdapter == null)
            {
                reservationAdapter = new ReservationAdapter(bus);
            }

            return(new ReadModelFacade(roomsAdapter, hotelAdapter, reservationAdapter, bus));
        }
Beispiel #11
0
 public ReadModelFacade(IProveerPizzas pizzasProvider, IProveerPizzeria pizzeriaProvider, IProveerPedido pedidoProvider, ISubscribeToEvents bus)
 {
     this.pizzasProvider    = pizzasProvider;
     this.pizzeriasProvider = pizzeriaProvider;
     this.pedidosProvider   = pedidoProvider;
 }