Using Unity to Implement a Factory Pattern

I could not find any examples of how to use unity to configure a simple factory and return a poco so after many attempts I got this working and I thought I'd share.

First I have generic Factory:

public class ServiceCommandFactory : IServiceCommandFactory
{
 public IServiceCommand CreateInstance() where T :  IServiceCommand, new()
 {
     return new T();
 }
}

No comments: