0

Im new to Autofac and finding myself repeating a lot of this....

builder.RegisterType<ConcreteService<EntityA>>().As<IService<EntityA>>();
builder.RegisterType<ConcreteService<EntityB>>().As<IService<EntityB>>();

EntityA, EntityB, EntityC and so on.. all inherit from EntityBase, so i want to instruct Autofac to always use ConcreteService<x> when it needs to create an implementation of IService<x> as long as x inherits from EntityBase

I am aware that the AssemblyScanner in Autofac may be able to help with this, although i am struggling to find documentation that goes far enough into it.

Any pointers appreciated.

Baldy
  • 3,621
  • 4
  • 38
  • 60
  • possible duplicate of [Resolving Generic Interface with Autofac](http://stackoverflow.com/questions/1189519/resolving-generic-interface-with-autofac) – Steven Jun 22 '11 at 16:37

1 Answers1

1

I think the answer to this question (stackoverflow) may also answer your question.

Community
  • 1
  • 1
vhallac
  • 13,301
  • 3
  • 25
  • 36