Reflection: Get all inherited classes of a base class

Adam D. Ruppe destructionator at gmail.com
Wed Dec 26 08:06:05 PST 2012


On Tuesday, 25 December 2012 at 18:26:29 UTC, nrgyzer wrote:
> Thanks Adam, that's exactly what I need... is it possible to 
> call a static method only using TypeInfo_Class or do I need to 
> call the constructor using create-method?

No, to call a static method you'd have to get to the compile time 
class; you'd have to actually do A.myName or cast(A) on a created 
object.

Like Jacob said though, the name is available as classinfo.name.

Anything else would best be done with an interface you can cast 
to and call some abstract methods.


BTW, it is potentially possible to do something with the magic 
RTInfo but I don't think that's available outside the druntime, 
so while we could potentially do more in theory, in practice 
probably not right now. We'd have to work something out between 
druntime and user extensibility.


More information about the Digitalmars-d-learn mailing list