www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - introspection woes...

Trying to play with introspection.
trying o, for a given object, to check its property by name.
Experimenting with the function below.

1. it doesn't compile! mi.name() seems to be a problem?
2. match is always null! even though I pass the name of an existing property 
and / or field!

===============
Object getelement(Object o, string aname)
{
    if (!o)
        return null;

    auto ci = o.classinfo;
    writefln("class: %s", ci.name);
    auto match = ci.getMembers(aname);

    foreach(mi ; ci.getMembers(null))
    {
        writefln("%s . %s", ci.name, mi.name());
    }
    //writefln("match: %s", match);
    return o;
}
============== 
Jun 13 2011