コード例 #1
0
        partial void OnCreateContainer(UnityContainer container)
        {
            var serializer = container.Resolve<ITextSerializer>();
            var metadata = container.Resolve<IMetadataProvider>();

            var commandBus = new CommandBus(new MessageSender(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Commands"), serializer);
            var eventBus = new EventBus(new MessageSender(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Events"), serializer);

            var commandProcessor = new CommandProcessor(new MessageReceiver(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Commands"), serializer);
            var eventProcessor = new EventProcessor(new MessageReceiver(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Events"), serializer);

            container.RegisterInstance<ICommandBus>(commandBus);
            container.RegisterInstance<IEventBus>(eventBus);
            container.RegisterInstance<ICommandHandlerRegistry>(commandProcessor);
            container.RegisterInstance<IProcessor>("CommandProcessor", commandProcessor);
            container.RegisterInstance<IEventHandlerRegistry>(eventProcessor);
            container.RegisterInstance<IProcessor>("EventProcessor", eventProcessor);

            // Event log database and handler.
            container.RegisterType<SqlMessageLog>(new InjectionConstructor("MessageLog", serializer, metadata));
            container.RegisterType<IEventHandler, SqlMessageLogHandler>("SqlMessageLogHandler");
            container.RegisterType<ICommandHandler, SqlMessageLogHandler>("SqlMessageLogHandler");

            RegisterRepository(container);
            RegisterEventHandlers(container, eventProcessor);
        }
コード例 #2
0
 private void RegisterEventHandlers(UnityContainer container, EventProcessor eventProcessor)
 {
     eventProcessor.Register(container.Resolve<RegistrationProcessRouter>());
     eventProcessor.Register(container.Resolve<OrderViewModelGenerator>());
     eventProcessor.Register(container.Resolve<PricedOrderViewModelGenerator>());
     eventProcessor.Register(container.Resolve<ConferenceViewModelGenerator>());
     eventProcessor.Register(container.Resolve<SeatAssignmentsViewModelGenerator>());
     eventProcessor.Register(container.Resolve<SeatAssignmentsHandler>());
     eventProcessor.Register(container.Resolve<global::Conference.OrderEventHandler>());
     eventProcessor.Register(container.Resolve<SqlMessageLogHandler>());
 }
コード例 #3
0
 public given_event_processor()
 {
     this.receiverMock = new Mock<IMessageReceiver>();
     this.processor = new EventProcessor(this.receiverMock.Object, CreateSerializer());
 }
コード例 #4
0
 public given_event_processor()
 {
     System.Diagnostics.Trace.Listeners.Clear();
     this.receiverMock = new Mock<IMessageReceiver>();
     this.processor = new EventProcessor(this.receiverMock.Object, CreateSerializer());
 }