How do I register dependencies with Windsor that are in different layers of the application?

2

How to register dependencies with Windsor that are in different layers of the application?

I do not want to be referencing all the application layers in the presentation layer as most do around.

I have the following error that I know because it happens, I wonder if anyone could help to register those dependencies that are in other layers of the application without having to be referencing everything in the presentation layer.

  

Can not create component 'BlogNetApp.Implementation.ServiceAppUser'   as it has dependencies to be satisfied.

     

'BlogNetApp.Implementation.ServiceAppUser' is waiting for the   following dependencies:   - Service 'BlogNetDomain.Interfaces.Services.IUsuarioService' which was not registered.

I'm using C # NET MVC Windsor container.

namespace BlogNet.Windsor
{
    public class PresentationInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For<IServiceAppUsuario>().ImplementedBy<ServiceAppUsuario>(),
                Component.For<IServiceAppRole>().ImplementedBy<ServiceAppRole>(),
                Component.For<IServiceAppQuote>().ImplementedBy<ServiceAppQuote>()
                );
        }
    }
}

As I said before, it is giving error because it is not being registered the dependencies that are in another layer. I do not want to reference the other layers in the presentation layer.

    
asked by anonymous 22.05.2015 / 19:55

1 answer

0
The composition root - the place where the dependencies are registered - is not part of any of the layers of the application. Hence the name, root .

So, composition root has (and should) reference all components of the application, regardless of their layers.

    
23.05.2015 / 00:15