Skip to content

Instantly share code, notes, and snippets.

@andreabalducci
Created November 18, 2012 10:13
Show Gist options
  • Select an option

  • Save andreabalducci/4104457 to your computer and use it in GitHub Desktop.

Select an option

Save andreabalducci/4104457 to your computer and use it in GitHub Desktop.
take 1 : inprocess engine
Container.Register(
Component
.For<ICommandDispatcher>()
.ImplementedBy<DefaultCommandDispatcher>(),
Component
.For<IEventBus>()
.ImplementedBy<InProcessEventBus>()
.LifeStyle.Singleton,
Component
.For<IEngine>()
.ImplementedBy<AcmeEngine>(),
Component
.For<ICommandSender>()
.ImplementedBy<DefaultCommandSender>(),
Component
.For<IRepositoryEventListener>()
.ImplementedBy<RepositoryEventsListener>()
.LifestyleSingleton(),
Component
.For<ICommandHandlerCatalog>()
.ImplementedBy<CommandHandlerCatalog>(),
Classes
.FromAssemblyContaining<AggregateRoot>()
.BasedOn(typeof(IRepository<>))
.WithServiceAllInterfaces()
.LifestyleTransient(),
Classes
.FromAssemblyInDirectory(new AssemblyFilter("bin", "Acme.*"))
.BasedOn(typeof(IEventHandler<>))
.WithServiceAllInterfaces()
.LifestyleScoped(),
Component
.For<IStorageConnection>()
.UsingFactoryMethod(t => new MongoConnection("Acme"))
.LifestylePerWebRequest(),
Component
.For<IControllerFactory>()
.ImplementedBy<AcmeControllerFactory>(),
Classes
.FromThisAssembly().BasedOn<IController>()
.WithService.Self().LifestyleTransient(),
Classes
.FromAssemblyInDirectory(new AssemblyFilter("bin", "Acme.*"))
.BasedOn(typeof(IQueryModelWriter<>))
.WithServiceAllInterfaces()
.LifestyleScoped(),
Classes
.FromAssemblyInDirectory(new AssemblyFilter("bin", "Acme.*"))
.BasedOn(typeof(IQueryModelReader<>))
.WithServiceAllInterfaces()
.LifestyleScoped()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment