I am trying to get an object using TRttiContext.FindType(QualifiedTypeName)
. Here is what I have:
program MissingRTTI; {$APPTYPE CONSOLE} uses System.SysUtils, RTTI, Classes; type TMyClass = class(TObject) end; var rCtx: TRttiContext; rType: TRttiInstanceType; begin rCtx := TRttiContext.Create(); rType := rCtx.GetType(TypeInfo(TMyClass)) as TRttiInstanceType; if (rType <> nil) then begin WriteLn('Type found using TypeInfo'); end; rType := rCtx.FindType(TMyClass.QualifiedClassName) as TRttiInstanceType; if (rType <> nil) then begin WriteLn('Type found using qualified class name.'); end; ReadLn; rCtx.Free(); end.
Unfortunately, only rCtx.GetType
seems to be looking for the right type. (I also tried to list all types using GetTypes. The desired type does not appear in the resulting array.) Does anyone know how to get the compiler to emit RTTI for this type?
source share