Picking Up Repositories With Structuremap

Posted by alphadogg on Stack Overflow See other posts from Stack Overflow or by alphadogg
Published on 2010-05-27T02:10:06Z Indexed on 2010/05/27 2:11 UTC
Read the original article Hit count: 263

I am not sure how to use StructureMap to scan for all repositories in a particular namespace. Most repositories take the form:

namespace CPOP.Infrastructure.Repositories
{
    public class PatientRepository : LinqRepository<Patient>, IPatientRepository
    {
    }
}

namespace CPOP.Infrastructure.Repositories
{
    public class LinqRepository<T> : Repository<T>, ILinqRepository<T>
    {
    }
}

namespace CPOP.Domain.Contracts.Repositories
{
    public interface IPatientRepository : ILinqRepository<Patient>
    {
    }
}

I tried:

x.Scan(scanner =>
{
    scanner.Assembly(Assembly.GetExecutingAssembly());
    scanner.ConnectImplementationsToTypesClosing(typeof(ILinqRepository<>));
})

But, it only picks up the LinqRepository class. What's the best way to pick up the various repositories I'll be dumping in there?

© Stack Overflow or respective owner

Related posts about interface

Related posts about dependency-injection