Beispiel #1
0
        public void Init(IUnityContainer container)
        {
            Database.DefaultConnectionFactory = new ConnectionFactory(Database.DefaultConnectionFactory);
            Database.SetInitializer<SketchDbContext>(null);
            Database.SetInitializer<EventStoreDbContext>(null);

            container.RegisterType<ITextSerializer, JsonSerializer>();
            var eventBus = new InMemoryEventBus();
            container.RegisterInstance<IEventBus>(eventBus);

            foreach (var handler in container.ResolveAll<IEventHandler>())
            {
                eventBus.Register(handler);
            }
        }
Beispiel #2
0
        public void Init(IUnityContainer container)
        {
            container.RegisterType<ITextSerializer, JsonSerializer>();
            var eventBus = new InMemoryEventBus();
            container.RegisterInstance<IEventBus>(eventBus);
            var commandBus = new InMemoryCommandBus();
            container.RegisterInstance<ICommandBus>(commandBus);

            container.RegisterType<IEventStore, SqlEventStore>();

            foreach (var handler in container.ResolveAll<ICommandHandler>())
            {
                commandBus.Register(handler);
            }

            foreach (var handler in container.ResolveAll<IEventHandler>())
            {
                eventBus.Register(handler);
            }
        }