Unity – Constructors with Parameters

Microsoft Unity is a great library to use for a dependency injection container. It has support for constructor, property, and method call injection. Typically you’ll use constructor injection. I wanted to use it for a class whose constructor took parameters. Here’s an example I’ve created to show what I wanted to do: First I have an interface for logging – ILogger:

Then I have an actual class that implements this interface – FileLogger:

In my program I create the Unity container. I then want to register my FileLogger class as an implementation of the ILogger interface. This part…
Read more →