private Configuration() { _bus = new MessageBus(); var eventStore = new SqlEventStore(_bus); var repository = new DomainRepository(eventStore); var commandService = new AccountApplicationService(repository); _bus.RegisterHandler<RegisterAccountCommand>(commandService.Handle); _bus.RegisterHandler<DebitAccountCommand>(commandService.Handle); _bus.RegisterHandler<UnlockAccountCommand>(commandService.Handle); var infoProjection = new AccountInfoProjection(); _bus.RegisterHandler<AccountRegisteredEvent>(infoProjection.Handle); _bus.RegisterHandler<AccountLockedEvent>(infoProjection.Handle); _bus.RegisterHandler<AccountUnlockedEvent>(infoProjection.Handle); var balanceProjection = new AccountBalanceProjection(); _bus.RegisterHandler<AccountRegisteredEvent>(balanceProjection.Handle); _bus.RegisterHandler<AccountDebitedEvent>(balanceProjection.Handle); var notification = new NotificationProjection(); _bus.RegisterHandler<AccountRegisteredEvent>(notification.Handle); _bus.RegisterHandler<AccountDebitedEvent>(notification.Handle); _bus.RegisterHandler<AccountLockedEvent>(notification.Handle); _bus.RegisterHandler<AccountUnlockedEvent>(notification.Handle); _bus.RegisterHandler<OverdrawAttemptedEvent>(notification.Handle); _readModel = new ReadModelFacade(balanceProjection, infoProjection, notification); var events = eventStore.GetAllEventsEver(); _bus.Publish(events); }
public ReadModelFacade(AccountBalanceProjection balance, AccountInfoProjection info, NotificationProjection notification) { AccountBalances = balance.AccountBalances; AccountInfos = info.AccountInfos; Notifications = notification.Notifications; }