1
votes

I have a set of WebApi, MVC and windows service apps and a logging library (based on nLog). The logging library is packaged as a nuget (if that matters). All the clients and the logging library use Castle Windsor. The logging library has a complex set of dependencies and currently in all the projects that use it I pasted a big block of registrations.

Is there a way to make the library use a set of default dependencies (registered automatically inside it) and change those in the clients only if they need a non-default option?

1

1 Answers

3
votes

You can create an installer for managing the dependencies:

public class RepositoriesInstaller : IWindsorInstaller
{
   public void Install(IWindsorContainer container, IConfigurationStore store)
   {
      //container.Register();
   }
}

Then the clients can install it in their container like this:

container.Install(new RepositoriesInstaller());

You can either include this installer in your library (that would mean your library would be dependent upon Castle Windsor) or create another package (MyLib.CastleWindsor etc) that contains the installer.