public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register(Component.For(typeof(TransactionalCommandHandlerDecorator <,>)) .LifestyleScoped()); container.Install(new CommandBusInstaller()); container.Register(Classes.FromAssemblyContaining <BrandCommandHandler>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Classes.FromAssemblyContaining <BrandDomainService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Install(new NotifyInstaller()); var autoMapperProfiles = typeof(BrandProfile).Assembly.GetTypes() .Where(x => x.IsSubclassOf(typeof(Profile))) .Select(Activator.CreateInstance) .OfType <Profile>() .ToList(); Mapper.Initialize(cfg => { autoMapperProfiles.ForEach(cfg.AddProfile); }); container.Register(Classes.FromAssemblyContaining <BrandQueryService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Classes.FromAssemblyContaining <ProductDomainService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Component.For <IDomainEventHandlerFactory>().ImplementedBy <DomainEventHandlerFactory>().LifestyleScoped()); //register repository components container.Register(Component.For <IContext>().ImplementedBy <DataContext>() .LifestyleScoped()); container.Register(Component.For(typeof(IRepository <>)).ImplementedBy(typeof(Repository <>)) .LifestyleScoped()); container.Register(Component.For <ISeqRepository>().ImplementedBy <SeqRepository>().LifestyleScoped()); container.Register(Component.For <ReadOnlyDataContext>().LifestyleScoped()); container.Register(Component.For(typeof(IReadOnlyRepository <,>)).ImplementedBy(typeof(ReadOnlyRepository <,>)) .LifestyleScoped()); DataContext.ExecuteMigration(); ReadOnlyDataContext.ExecuteMigration(); DomainEventServiceLocator.SetContainer(container); }
static DomainEventDispatcher() { DomainEventHandlerFactory = DomainEventServiceLocator.GetInstance <IDomainEventHandlerFactory>(); }