It would be really helpful to have an EnumWrapper class that would be of generic type Enum. Then you could set it up and pass it around as an argument instead of needing to write methods that use the Names and Ordinals collection.
Pseudo code: This code could be called for any Enum,
var
MyEnumWrapper: EnumWrapper MyEnum;
MyName: Text;
MyCaption: Text;
begin
for each MyName in MyEnumWarpper.Names do begin
MyCaption := Format(MyName);
if MyCaption <> MyName then begin
Message('Mismatched Name: %1 and Caption: %2', MyName, MyCaption);
end;
end;
end;
Comments
This is better pseudo code for an EnumRef that would mimic RecordRef and FieldRef functionality.
var
MyEnumRef: EnumRef;
MyName: Text;
MyCaption: Text;
begin
MyEnumRef := EnumRef.GetEnum(Enum::MyEnum);
for each MyName in MyEnumRef.Names do begin
MyCaption := Format(MyName);
if MyCaption MyName then begin
Message('Mismatched Name: %1 and Caption: %2', MyName, MyCaption);
end;
end;
end;
Category: Development
Think of it as an EnumRef in the same manner as RecordRef and FieldRef. You would then have access to all the functionality of any Enum.
EnumRef.GetEnum(MyEnum);
Category: Development
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team