【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
还没有人抢沙发呢~