This question is an opposite of How to find types that are direct descendants of a base class?
If this is the inheritance hierarchy I have,
class Base
{
}
class Derived1 : Base
{
}
class Derived1A : Derived1
{
}
class Derived1B : Derived1
{
}
class Derived2 : Base
{
}
I need a mechanism to find all the sub types of Base
class in a particular assembly which are at the end of the inheritance tree. In other words,
SubTypesOf(typeof(Base))
should give me
-> { Derived1A, Derived1B, Derived2 }
This is what I have come up with. Not sure if some more elegant/efficient solutions exist..
And for sake of completeness, I will repost the answer for direct descendants given here