Skip to main content

Get Enumeration Type

You can get an IEnum object from an enumeration name by using the GetEnum method of the IMetamodels object.

public void GetEnum(ICommandContext c, ICommandParams p) 
{
//Get the metamodels
IMetamodels metamodels = c.App.Workspace.CurrentProject.Profile.Metamodels;

var en = metamodels.GetEnum("RequirementType");

//Print the display name of the enumeration
c.App.Output.WriteLine("sample", $"Enum: {en.DisplayName}");

//Print the literal of the enumeration
foreach (var literal in en.Literals)
{
c.App.Output.WriteLine("sample", $"Literal: {literal.DisplayName} ");
}
}