【Dynamics AX】判断对象是否是某个类的子类实例

    调用SysDictClass类的两个函数

    static boolean isSuperclass(classId  _id, classId  _potentialAncestorId)
    static boolean isEqualOrSuperclass(classId  _id, classId  _potentialAncestorId)



    实例代码

    SalesTableType          stt;
    SalesTableType_Journal  stt_j;
    ;
    
    // This is true as stt is an ''instance'' of SalesTableType
    if (SysDictClass::isEqualOrSuperclass(classidget(stt), classnum(SalesTableType)))
    {
        // Code here will be run
    }
    
    // This is true as stt_j is a ''subclass'' of SalesTableType
    if (SysDictClass::isEqualOrSuperclass(classidget(stt_j), classnum(SalesTableType)))
    {
        // Code here will be run
    }
    
    // This is true as stt_j is an ''instance'' of SalesTableType_Journal
    if (SysDictClass::isEqualOrSuperclass(classidget(stt_j), classnum(SalesTableType_Journal)))
    {
        // Code here will be run
    }
    
    // This is FALSE as stt is NOT an instance or subclass of SalesTableType_Journal
    if (SysDictClass::isEqualOrSuperclass(classidget(stt), classnum(SalesTableType_Journal)))
    {
        // Code here will NOT be run
    }

    参考:Determining if an object is a subclass



    本博客所有文章如无特别注明均为原创。
    复制或转载请以超链接形式注明转自枫芸志,原文地址《【Dynamics AX】判断对象是否是某个类的子类实例
    标签:
    分享:

还没有人抢沙发呢~

无觅相关文章插件,快速提升流量