Title


I am trying to invoke a method using RTTI calls but I been struggling to do so

Here is my sample code

{$RTTI METHODS([vcPublic, vcProtected, vcPrivate])}
TBill = class sealed
private
Procedure Extract ;
procedure Tansform
Procedure Load;
public
constructor create (aFlagDb : Boolean); overload;
Procedure InvokeMethod(aMethodName: string; const Args: array of TValue);
end

procedure InvokeMethod(aMethodName: string; const Args: array of TValue);
var
Method :TRttiMethod;
rtype :TRTTIType;
begin
rtype := TRTTIContext.Create.GetType('TBill');

Method := rtype.GetMethod('Extract'); -> Returns Nil why?
Method.Invoke(self, Args);

end

Any Ideas?

Comments

  1. Hi Alexander sorry thats what i typed
    rtype := TRTTIContext.Create.GetType(TBill);
    I even tried
    Method := rtype.GetMethod('procedure Extract') but still same result

    ReplyDelete
  2. Why you don't provide real code?
    The problem I think is
    {$RTTI EXPLICIT METHODS([vcPublic, vcProtected, vcPrivate])}

    ReplyDelete
  3. Hi Alexander,

    I found the problem i need to specify
    {$RTTI INHERIT METHODS([vcPublic, vcPublished, vcPrivate, vcProtected]) }

    instead of
    I found the problem i need to specify
    {$RTTI I METHODS([vcPublic, vcPublished, vcPrivate, vcProtected]) }

    ReplyDelete

Post a Comment