I'm registering my services, repositories, etc like this:
http://blog.viabrains.com/2008/10/register-services-in-windsor.html
Couldn't find this feature in microkernel so I implemented it and the patch is attached. Is this something useful?
Now I can write:
//register all services
container.Register(
AllTypes.FromAssembly(typeof (ProductService).Assembly)
.BasedOn<IService>()
.WithService.FromInterface(typeof (IService)));
//register all repositories
container.Register(
AllTypes.FromAssembly(typeof(ProductRepository).Assembly)
.BasedOn<IRepository>()
.WithService.FromInterface(typeof(IRepository)));
This will be the same as
// Register all services
container.Register(
Component
.For<IProductService>()
.ImplementedBy<ProductService>());
container.Register(
Component
.For<IOrderService>()
.ImplementedBy<OrderService>());
// and so on...
If this patch is approved then Castle.MicroKernel-vs2005.csproj needs to be modified as well, I think?
Thoughts? I'm not that happy with the name FromInterface() thou
Cheers,
Martin
public class ProductService : IProductService
{
}
public interface IProductService : IService
{
}