0

Let's say I have an interface called IBaseInterface. Then there are two interfaces that inherit this interface:

IFirstConcreteInterface : IBaseInterface

and

ISecondConcreteInterface : IBaseInterface

Now I have two classes that implement the concrete interfaces:

FirstConcreteClass : IFirstConcreteInterface

and

SecondConcreteClass : ISecondConcreteInterface

The instances of these classes have been registered with autofac at Startup.cs.

Here's my question:

How can I get the instances of all classes whose interfaces inherit from IBaseInterface (instance of FirstConcreteClass and SecondConcreteClass in this example) by using autofac? I don't need them in the Startup.cs but in a different class.

Thank you very much.

MatterOfFact
  • 1,253
  • 2
  • 18
  • 49
  • Related: [Get a list of all registered objects implementing a certain interface](https://stackoverflow.com/questions/24369861/get-a-list-of-all-registered-objects-implementing-a-certain-interface) and [Get all registered implementations of an interface in Autofac](https://stackoverflow.com/questions/14061472/get-all-registered-implementations-of-an-interface-in-autofac) – A Friend Mar 08 '19 at 16:15
  • From a comment on the first linked question: "Autofac doesn't really support doing what you're asking" but there are valid answers – A Friend Mar 08 '19 at 16:16
  • Yes, the following answer worked for me: https://stackoverflow.com/a/24389668/9888512 – MatterOfFact Mar 08 '19 at 17:06

0 Answers0