Delphi Insufficient RTTI available to support this operation -
i new using rtti , i'm stuck on error.
i trying call procedure name , pass parameter array of tvalue
. first problem getparameters
returns array of 0 length (instead of 1), , can't ignore try call procedure empty array.
here's code:
procedure tformgenpopupmessaggi.execmethod(form : tobject; methodname:string; const args: array of tvalue); var r : trtticontext; t : trttitype; m : trttimethod; lparams : tarray<trttiparameter>; begin t := r.gettype(tformacqgestionerichiesteacquisto); m in t.getdeclaredmethods if (m.parent = t) , (m.name = methodname)then begin lparams := m.getparameters; showmessage(inttostr(length(lparams))); m.invoke(tformacqgestionerichiesteacquisto.create(self), parametri); end; end; procedure tformgenpopupmessaggi.eseguimessaggio(sender : tobject); var procedura, tipoclasse : string; argomenti : string; arrayargomenti : array of tvalue; idmessaggio, idelenco : integer; : integer; c : trtticontext; o : tobject; begin [...]` procedura := qgenerica.fieldbyname('nome_procedura').asstring; [...] tipoclasse := 'u' + copy(qgenerica.fieldbyname('nome_form').asstring, 6, 1000) + '.' + qgenerica.fieldbyname('nome_form').asstring; o := (c.findtype(tipoclasse) trttiinstancetype).metaclasstype.create; if length(arrayargomenti) = 0 execmethod(o, procedura,[]) else execmethod(o, procedura, arrayargomenti); [...] end;
and called procedure is:
procedure trovarichiesta(id : integer);
declared in public in class type tformacqgestionerichiesteacquisto
. code find procedure name correctly, create new form class correctly don't give me parameter showmessage(inttostr(length(lparams))) result 0
.
all other variables correctly initialized. there type of keys define, in order enable rtti?
to detailed rtti turn on {$typeinfo}
, {$methodinfo}
compiler directives explained here.
Comments
Post a Comment