mardi 11 juillet 2017

Get all classes that implement a certain abstract class

I'm trying to get all classes that implement a certain abstract class. I'm trying to do that with the following code:

var type = typeof(BaseViewComponent);
var types = Assembly
    .GetEntryAssembly()
    .GetReferencedAssemblies()
    .Select(Assembly.Load)
    .SelectMany(s => s.GetTypes())
    .Where(p => type.IsAssignableFrom(p));

But thus far I'm only able to get the abstract class it self. Not any class that implements that base class.

What do I have to change to get all the classes that implement this abstract base class?





Aucun commentaire:

Enregistrer un commentaire