次の方法で共有


Managed enumeration types and X++

Currently it is painful to use managed enumeration types in X++, although not impossible,

This example came up the other day: A user needed to access an enumeration type called PsDirectoryFilterEnum in a namespace called ProductStudio. He wanted to assign the value PsDirectoryFilterEnum.psDirectoryFilterPSProducts to some variable.

Currently the only wat of doing this is by using the following code using parseClrEnum supplying both the name of the enumeration type and the enumeration literal as strings:

 ProductStudio.PsDirectoryFilterEnum psDirEnum =
        ClrInterop::parseClrEnum('ProductStudio.PsDirectoryrFilterEnum', 'psDirectoryFilterPSProducts');

At some point in the future we'll probably allow the user to declare enumerations more naturally, like

ProductStudio.PsDirectoryrFilterEnum enum =
ProductStudio.PsDirectoryrFilterEnum::psDirectoryFilterPSProducts;

using the familiar double colon syntax to access the enumeration literal, just as if it had been a normal X++ enumeration.

Comments

  • Anonymous
    July 29, 2010
    The comment has been removed