Get all fields of an enumeration
You can get fields of a specific type from the list of fields. The following is an example of getting type information for an enumeration field in a model.
public void OutputEnumFields(ICommandContext c, ICommandParams p)
{
    //Get all fields of the metaclass of the currently displayed model
    var fields = c.App.Workspace.CurrentModel.Metaclass.Fields.Values;
    foreach (var field in fields)
    {
        //Exclude fields that start with $, as they are system fields
        if (field.Name.StartsWith("$")) continue;
        //Exclude fields that are not enumerations
        var enumType = field.TypeEnum;
        if (enumType == null) continue;
        //Output the display name of the enumeration
        c.App.Output.WriteLine("sample", $"Enumeration name: {enumType.DisplayName}");
    }
}
Note
When you get fields using the API, you can also get system-defined fields at the same time. Fields defined by the system follow the following rules, so exclude them if you do not need them.
- The name (IField.Name) is prefixed with "$"
- The name (IField.Name) is prefixed with "___"