Answer the question
In order to leave comments, you need to log in
How can I get a list of interfaces of only inheritors of a certain base interface from a Type instance?
Let's say there is a basic interface IBaseIntarface and several interfaces inheriting it IMyIntarface1, IMyIntarface2 and so on.
There is a class that implements these heirs (maybe several of them), plus there may be some more
//IBaseIntarface base_intarface;
Type type = base_intarface.GetType();
List<Type> list_types = type.GetInterfaces().ToList();
List<Type> list_types = type
.GetInterfaces()
.Where(it => it != typeof(IBaseIntarface))
.ToList();
List<Type> list_types = type
.GetInterfaces()
.Where(it => it != typeof(IBaseIntarface) && it is IBaseIntarface)
.ToList();
Answer the question
In order to leave comments, you need to log in
https://stackoverflow.com/questions/26733/getting-...
The approach is to go through all the types in the assembly and see if they implement the given interface.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question