// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
program Project7;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Rtti,
System.StrUtils;
type
TEnumerations = TArray<TRttiEnumerationType>;
function getAllEnumerations(): TEnumerations;
var
context: TRttiContext;
rttiType: TRttiType;
begin
Result := [];
context := TRttiContext.Create();
for rttiType
in context.GetTypes()
do
if (rttiType
is TRttiEnumerationType)
then
Result := Result + [rttiType
as TRttiEnumerationType];
end;
procedure printEnumerations(
const enumerations: TEnumerations);
inline;
var
enumeration: TRttiEnumerationType;
begin
for enumeration
in enumerations
do
WriteLn(enumeration.ToString());
end;
procedure checkForEnumString(
const enumeration: TRttiEnumerationType;
const stringValue:
String
);
begin
if System.StrUtils.MatchStr(stringValue, enumeration.GetNames())
then
WriteLn(stringValue, '
is a value of ', enumeration.ToString());
end;
procedure p();
const
someEnumString = '
dkStatic';
var
enumeration: TRttiEnumerationType;
begin
for enumeration
in getAllEnumerations()
do
checkForEnumString(enumeration, someEnumString);
end;
begin
try
p();
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
readln;
end.