jeudi 10 août 2017

Group types by common base class in given assembly

In a given assembly, I want to find all types that have a common base class, but without specifying the base class, for example:

A : Base, IInterface
B : Base, IInterface
C : Base, IInterface
X : Other, IInterface
Y : Other, IInterface

I have 2 groups, A,B,C (inheriting from Base) and X,Y (inheriting from Other). Base and Other are abstract and all implements a common interface.

The method signature could be something like:

public IEnumerable<IGrouping<Type, IEnumerable<Type>>> FindGroups(Assembly assembly, Type @interface)
{
}

How can I create those groups?





Aucun commentaire:

Enregistrer un commentaire