Показать сообщение отдельно
Старый 06.07.2018, 11:11   #316  
dech is offline
dech
Участник
Аватар для dech
Самостоятельные клиенты AX
 
642 / 347 (13) ++++++
Регистрация: 25.06.2009
Адрес: Омск
Записей в блоге: 3
Недавно потребовалось в АХ 4.0 просмотреть поля на всех таблицах определенного EDT типа. Соответственно решил использовать метод SysDictField.isDerivedFrom(). В итоге находилось 0 полей. Когда заглянул внутрь, дико ужаснулся. Код работает нормально только для вещественного типа и то как-то через одно место.
X++:
/*
    Returns true if the Extended Data Type property field is derived from the extended data type.
    Use extendedTypeNum() to get the id of type.
*/
boolean isDerivedFrom(extendedTypeId id)
{
    Types fieldType;
    extendedTypeId userTypeId;
    DictType dictType;
    boolean retval  = false;
    ;
    fieldType = this.baseType();

    if(fieldType == Types::Real)
    {
        dictType = new DictType(this.typeId());
        if (this.typeId() == id)
            retval = true;

        if(!retval)
        {
            userTypeId = this.typeId();
            dictType = new DictType(userTypeId);

            while(dictType!=null && !retval)
            {
                if (userTypeId == id)
                    retval = true;
                else
                {
                   userTypeId = dictType.extend();
                   dictType = new DictType(userTypeId);
                }
            }
        }
    }

    return retval;
}
Глянул код в АХ2012. Все кристально чисто:
X++:
/*
    Returns true if the Extended Data Type property field is derived from the extended data type.
    Use extendedTypeNum() to get the id of type.
*/
boolean isDerivedFrom(extendedTypeId id)
{
    return SysDictType::isEqualOrExtending(this.typeId(), id);
}
__________________
// no comments