I just started using Castle Windsor (3.3.0) for the very first time and I got stuck on convention based registration.
I would like to register as much as possible by name convention (IDummyService -> DummyService):
var container = new WindsorContainer();
container.Register(Types.FromThisAssembly().Pick().WithServiceDefaultInterfaces());
container.Register(Component.For<IDummyService>().ImplementedBy<DummyService>().LifestyleSingleton()); // So long, I'm throwing here...
... but of course to be able to change some of just registered components little bit (changing life time management, constructor parameters etc.)
Because I want to keep registration as simple as it could be, I would like to avoid complex conditions. Only solution I found is simple - to move custom stuff above name convention:
var container = new WindsorContainer();
container.Register(Component.For<IDummyService>().ImplementedBy<DummyService>().LifestyleSingleton()); // Do custom stuff first...
container.Register(Types.FromThisAssembly().Pick().WithServiceDefaultInterfaces()); // And convention at the end...
My question is now, is this right way how to solve my registration? I can see Castle Windsor is quite mighty in this area and would rather solve my task properly, unfortunately don't see much real-world examples.
One option would be to do the custom configuration by implementing the
IContributeComponentModelConstructioninterface - theProcessModelmethod is called for each component:You would then need to register this with the container prior to registering the other components: