public OrganizationApplicationService()
        {
            log4net.Config.XmlConfigurator.Configure();

            var container = new UnityContainer();
            var logger    = LogProvider.For <OrganizationApplicationService>();

            container.RegisterInstance(typeof(ILog), LogProvider.For <OrganizationApplicationService>(), new ContainerControlledLifetimeManager());
            container.RegisterType <AddOrganizationCommandHandler>();
            //container.RegisterType<AddEFOrganisationCommandHandler>();



            container.RegisterType <ChangeOrganizationCommandHandler>();
            container.RegisterType <OrganizationAddedEventHandler>();
            container.RegisterType <OrganizationAddedLegacyEventHandler>();

            //Factories
            //container.RegisterType(typeof(ICommandFactory<AddOrganizationCommand>),typeof(CommandFactory<AddOrganizationCommand, AxaAddOrganizationCommandExtension>));
            //container.RegisterType<IDomainFactory, AxaDomainFactory>();
            //container.RegisterType(typeof(ICommandFactory<>), typeof(CommandFactory<>));

            container.RegisterType <IDomainFactory, DomainFactory>();
            container.RegisterType(typeof(IDomainTracking <>), typeof(DomainTracking <>));

            //Repositories
            container.RegisterType <IOrganizationRepository, OrganizationRepository>();
            container.RegisterType(typeof(IEFGenericRepository <>), typeof(EFGenericRepository <>));
            container.RegisterType(typeof(IDapperGenericRepository <>), typeof(DapperGenericRepository <>));

            //container.RegisterType<DbContext, OrganisationDbContext>(new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(IGenericRepository <>), typeof(EFGenericRepository <>));

            //Command Processor
            paramore.brighter.commandprocessor.CommandProcessor commandProcessor = CreateCommandProcesor(container);

            container.RegisterInstance(typeof(IAmACommandProcessor), commandProcessor);

            var rmqMessageConsumerFactory = new RmqMessageConsumerFactory(logger);
            var rmqMessageProducerFactory = new RmqMessageProducerFactory(logger);

            var messageMapperFactory  = new UnityMessageMapperFactory(container);
            var messageMapperRegistry = new MessageMapperRegistry(messageMapperFactory);

            messageMapperRegistry.Register <AddOrganizationCommand, AddOrganizationCommandMessageMapper>();

            _dispatcher = DispatchBuilder.With()
                          .CommandProcessor(commandProcessor)
                          .MessageMappers(messageMapperRegistry)
                          .ChannelFactory(new InputChannelFactory(rmqMessageConsumerFactory, rmqMessageProducerFactory))
                          .ConnectionsFromConfiguration()
                          .Build();
        }
Beispiel #2
0
        public static void Run(UnityContainer container)
        {
            container.RegisterType <OrganizationQueryModule>();
            container.RegisterType <EFOrganizationQueryModule>();
            container.RegisterType <AddressQueryModule>();
            container.RegisterType <EFAddressQueryModule>();

            container.RegisterType <OrganizationCommandModule>();
            container.RegisterInstance(typeof(ILog), LogProvider.For <OrganizationService>(), new ContainerControlledLifetimeManager());
            container.RegisterType <AddOrganizationCommandHandler>();
            container.RegisterType <AddEFOrganisationCommandHandler>();



            container.RegisterType <ChangeOrganizationCommandHandler>();
            container.RegisterType <OrganizationAddedEventHandler>();
            container.RegisterType <OrganizationAddedLegacyEventHandler>();

            //Factories
            //container.RegisterType(typeof(ICommandFactory<AddOrganizationCommand>),typeof(CommandFactory<AddOrganizationCommand, AxaAddOrganizationCommandExtension>));
            //container.RegisterType<IDomainFactory, AxaDomainFactory>();
            container.RegisterType(typeof(ICommandFactory <>), typeof(CommandFactory <>));

            container.RegisterType <IDomainFactory, DomainFactory>();
            container.RegisterType(typeof(IDomainTracking <>), typeof(DomainTracking <>));

            //Repositories
            container.RegisterType <IOrganizationRepository, OrganizationRepository>();
            container.RegisterType(typeof(IDapperGenericRepository <>), typeof(DapperGenericRepository <>));
            container.RegisterType(typeof(IEFGenericRepository <>), typeof(EFGenericRepository <>));

            container.RegisterType <DbContext, OrganisationDbContext>(new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(IGenericRepository <>), typeof(EFGenericRepository <>));

            //Command Processor
            paramore.brighter.commandprocessor.CommandProcessor commandProcessor = CreateCommandProcesor(container);

            container.RegisterInstance(typeof(IAmACommandProcessor), commandProcessor);
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ControlBusSender"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 public ControlBusSender(CommandProcessor commandProcessor)
 {
     _commandProcessor = commandProcessor;
 }