1

Imagine interface

  • IRepository
  • IFooRepository : IRepository
  • IBarRepository : IRepository

With associated Repository:

  • FooRepository : RepositoryBase, IFooRepository
  • BarRepository : RepositoryBase, IBarRepository

I'm trying to do generic registration with structure map to register all my repository in one Registry to call my IoC with IFooRepository

public class DataRegistry : Registry
    {
        public DataRegistry()
        {
            Scan(x =>
            {
                x.AssemblyContainingType<RepositoryBase>();
                x.IncludeNamespaceContainingType<RepositoryBase>();
                //Todo Register EndWith Repository as ImplementedInterface
            });
        }
    }
Arnaud
  • 84
  • 1
  • 10

1 Answers1

0

This will enable you to resolve IFooRepository as an instance of FooRepository:

Scan(x =>
{
    x.AssemblyContainingType<RepositoryBase>();
    x.IncludeNamespaceContainingType<RepositoryBase>();
    x.WithDefaultConventions();

});

WithDefaultConventions connects all interfaces with classes having the same name (except the I). SingleImplementationsOfInterface will do in your case as well.

PHeiberg
  • 29,411
  • 6
  • 59
  • 81