Exemple #1
0
        public WebAppService(WebAppSettings settings)
        {
            var viewStore            = new CosmosStore(settings.CosmosEndpoint, settings.CosmosAuthKey, settings.DatabaseId, settings.ViewCollectionId);
            var stationDetailHandler = new StationDetailHandler(viewStore);
            var stationListHandler   = new StationListHandler(viewStore);

            var publisher = new LocalPublisher();

            publisher.RegisterHandler <StationCreated>(stationDetailHandler.Handle);
            publisher.RegisterHandler <StationRenamed>(stationListHandler.Handle);

            var stationRepository      = new CosmosEventRepository <Station>(settings.CosmosEndpoint, settings.CosmosAuthKey, settings.DatabaseId, settings.EventCollectionId, publisher);
            var stationCommandHandlers = new StationHandlers(stationRepository);

            var bus = new LocalBus();

            bus.RegisterHandler <CreateStation>(stationCommandHandlers.Handle);
            bus.RegisterHandler <RenameStation>(stationCommandHandlers.Handle);

            Bus        = bus;
            Publisher  = publisher;
            ViewFacade = new ViewFacade(viewStore);
        }