I need to get all types of an assembly that inherits some base class but only the first descendants. For instance if I have:
class Base
{
}
class FirstClass : Base
{
}
class SecondClass : FirstClass
{
}
Now
var directOnes = assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Base)));
should return only FirstClass
and not SecondClass
. Is there a way to find out?