I am using StructureMap as my IoC tool for Dependency Injection. I also use a generic contract for my repositories: IRepository<T>. When configuring StructureMap to use generic types, it must be done using the non-generic overload of the Registry.ForRequestedType method:
public class MainRegistry : Registry
{
protected override void configure()
{
. . .
ForRequestedType (typeof (IRepository<>))
.TheDefaultIsConcreteType (typeof (NHibernateRepository<>));
. . .
}
}
This allows me to receive a NHibernateRepository of the desired type when I request for an IRepository.