I’ve got an interface:
IRepository<T> where T : IEntity
while im knocking up my UI im using some fake repository implementations that just return any old data.
They look like this:
public class FakeClientRepository : IRepository<Client>
At the moment im doing this:
ForRequestedType<IRepository<Client>>()
.TheDefaultIsConcreteType<FakeRepositories.FakeClientRepository>();
but loads of times for all my IEntities. Is it possible to use Scan to auto register all my fake repositories for its respective IRepository?
Edit: this is as far as I got, but i get errors saying the requested type isnt registered 🙁
Scan(x =>
{
x.TheCallingAssembly();
x.IncludeNamespaceContainingType<FakeRepositories.FakeClientRepository>();
x.AddAllTypesOf(typeof(IRepository<>));
x.WithDefaultConventions();
});
Thanks
Andrew
There is an easier way to do this. Please see this blog posting for details: Advanced StructureMap: connecting implementations to open generic types
Doing it this way avoids having to create your own
ITypeScanneror conventions.