Example #1
0
        public ChannelActivity()
        {
            _store = new InMemoryStreamStore();
            var types = RegisterTypes();
            var repo  = new SqlStreamStoreRepository(_store, types);
            var bus   = new EventBus();

            _userService = new UserRegistrationHandlers(repo);
            var user = new UsersHandlers(repo);

            _readRepo = new InMemoryReadModelRepository();
            var channelHistoryService = new ChannelHistoryHandlers(_readRepo);

            _channelService = new ChannelCommandHandlers(repo);
            _chatService    = new ChatMessageHandlers(repo);
            bus.Register <ChannelCreated>(channelHistoryService.When);
            bus.Register <ChannelJoined>(channelHistoryService.When);
            bus.Register <ChannelLeft>(channelHistoryService.When);
            bus.Register <MessageSubmitted>(channelHistoryService.When);
            bus.Register <MessageEdited>(channelHistoryService.When);
            bus.Register <RegistrationStarted>(user.When);
            bus.Register <RegistrationSucceeded>(_userService.When);

            var _ = new AllStreamSubscriber(_store, bus, types, true);
        }
Example #2
0
        public AggregateReactions()
        {
            TypeMapper RegisterTypes()
            {
                var m = new TypeMapper();

                m.Register(typeof(RegistrationSucceeded),
                           nameof(RegistrationSucceeded));
                m.Register(typeof(RegistrationFailed),
                           nameof(RegistrationFailed));
                m.Register(typeof(RegistrationStarted),
                           nameof(RegistrationStarted));
                return(m);
            }

            _store = new InMemoryStreamStore();
            var types = RegisterTypes();

            _repo = new SqlStreamStoreRepository(_store, types);
            var users = new UsersHandlers(_repo);

            _bus.Register <RegistrationStarted>(users.When);

            _registration = new UserRegistrationHandlers(_repo);

            _bus.Register <RegistrationSucceeded>(_registration.When);
            _bus.Register <RegistrationFailed>(_registration.When);

            var _ = new AllStreamSubscriber(_store, _bus, types, true);
        }
Example #3
0
        public static void EventHandlers(IEventBus bus, IDocumentStorage readRepo, IRepository writeRepo)
        {
            var channelHistoryService = new ChannelHistoryHandlers(readRepo);
            var user        = new UsersHandlers(writeRepo);
            var userService = new UserRegistrationHandlers(writeRepo);

            bus.Register <ChannelCreated>(channelHistoryService.When);
            bus.Register <ChannelJoined>(channelHistoryService.When);
            bus.Register <ChannelLeft>(channelHistoryService.When);
            bus.Register <MessageSubmitted>(channelHistoryService.When);
            bus.Register <MessageEdited>(channelHistoryService.When);
            bus.Register <RegistrationStarted>(user.When);
            bus.Register <RegistrationSucceeded>(userService.When);
        }