You need to know the four rules in order to understand how it works:

1. You need to declare only one constructor per implementation with or without parameters (In order the container understand how to resolve the constructor because you don´t need to add any custom attribue)

2. You need to register the constructor parameters in the container so only interfaces are allow to be a valid parameter to resolve in the container.

   public class ClienteRepositorio:IClienteRepositorio
    {
        private readonly IConfiguracionRepositorio _configuracionRpt;
        public ClienteRepositorio(IConfiguracionRepositorio configuracionRepositorio)
        {
            _configuracionRpt = configuracionRepositorio;
        }

3. You can use properties to inject dependencies and they must be public if you want that the container find the required dependency

4. The Type of the property declared must be an interface (Just for author convention and coding best practices )

        private ILogger _logger;
        public ILogger Logger
        {
            set { _logger = value; }
        }

Last edited Jan 4, 2011 at 5:30 AM by jmho, version 2

Comments

No comments yet.