classidget获取object的id, 递归遍历所有方法 DictMethod | callObject | invokeObjectMethod

public static anytype invokeObjectMethod(Object _object, identifiername _methodName, boolean _tryBaseClass = false)
{
    DictClass  dictClass = new DictClass(classidget(_object));
    DictClass  dictClassBase;
    DictMethod dictMethod;
    int i;
;
    for (i=1; i<=dictClass.objectMethodCnt(); i++)
    {
        if (dictClass.objectMethod(i) == _methodName)
        {
            dictMethod = dictClass.objectMethodObject(i);
            if (dictMethod.parameterCnt() == 0)
            {
                // invokeObjectMethod is listed as a dangerous API. Just suppress BP error;
                // CAS is implemented by DictClass::callObject.

                // BP deviation documented
                return dictClass.callObject(_methodName, _object);
            }
            throw error(strfmt("@SYS87800", _methodName));
        }
    }

    if (_tryBaseClass && dictClass.extend())
    {
        dictClassBase = new DictClass(dictClass.extend());

        // BP deviation documented
        return SysDictClass::invokeObjectMethod(dictClassBase.makeObject(), _methodName, _tryBaseClass);
    }

    throw error(strfmt("@SYS60360", _methodName));
}

posted @ 2011-12-20 08:46  perock  阅读(477)  评论(0编辑  收藏  举报