Download the Common Instance Factory with WCF Extensions here and is also available on NuGet.
A while back I wrote a blog post on the Onion Architecture, an approach to building loosely-coupled applications where you can swap out particular components without affecting the rest of the application. They key to making it all work is the use of Dependency Injection, also known as Inversion of Control, to delegate creation of types to an external container. There are various ways to implement dependency injection, but the most common is a technique called “constructor injection,” in which a class provides a constructor that accepts one or more interfaces as parameters. Concrete implementations of each interface are registered with the DI container and supplied to the constructor when a request for the type is made from the container.
public class GreetingService : IGreetingService
{
private readonly IGreetingRepository _greetingRepository;
public GreetingService(