Using Aliases

[This is preliminary documentation and subject to change.]

An alias is a symbolic reference in either a class or instance declaration to an object located elsewhere in a MOF file. Alias names follow the same rules as instance and class names, except that they must begin with a dollar sign ($) to mark them as an alias. Underscores can appear in an alias name following the initial character. Aliases are typically used as shortcuts to lengthy object paths.

To define an alias, add the phrase "as $AliasName" to the instance or class declaration:

class MyClass as $MyClassAlias
{
}

instance of MyClass as $MyInstanceAlias
{
}

The following examples illustrate how to use an alias as a symbolic reference to an object path. Two classes are declared to describe a disk: the Disk class for the drive letter and the DiskRef class for its path. An alias is defined for the Disk class instance and is used as the value for the PathToDisk property in the DiskRef instance.

class Disk {
    [key]  string    DriveLetter;
};

class DiskRef 
{
    [key]  string    MyKey;
    Disk   ref       PathToDisk;
};

instance of Disk as $DiskAlias 
{
    DriveLetter = "c";
};

instance of DiskRef
{
    MyKey      =  "hello";
    PathToDisk = $DiskAlias;
}

Aliases have scope only within the MOF file in which they are declared. They are used at compile time to make it easy to establish references and are not available programmatically.

Note  WBEM supports forward-referencing but not circular aliases.