我想处理TRttiMethod
匿名方法。我怎么能这样做?
这是我希望事情如何工作的简化示例:
界面:
TMyClass = class
public
// this method will be acquired via Rtti
procedure Foo;
// this method shall return above Foo as anonymous method
function GetMethodAsAnonymous: TProc;
end;
执行:
function TMyClass.GetMethodAsAnonymous: TProc;
var
Ctx: TRttiContext;
RttiType: TRttiType;
RttiMethod: TRttiMethod;
begin
Ctx := TRttiContext.Create;
try
RttiType := Ctx.GetType(Self.ClassType);
RttiMethod := RttiType.GetMethod('Foo');
Result := ??????; // <-- I want to put RttiMethod here - but how?
finally
Ctx.Free;
end;
end;