There is an easier way to do this. Please see this blog posting for details: Advanced StructureMap: connecting implementations to open generic types
public class HandlerRegistry : Registry
{
public HandlerRegistry()
{
Scan(cfg =>
{
cfg.TheCallingAssembly();
cfg.IncludeNamespaceContainingType<FakeRepositories.FakeClientRepository>();
cfg.ConnectImplementationsToTypesClosing(typeof(IRepository<>));
});
}
}
Doing it this way avoids having to create your own ITypeScanner
or conventions.