I was wondering if you can help me with this:

I was wondering if you can help me with this:

I've got a generic field in a class:
fClass: T

and in the constructor I pass a class for fClass and I want to go through the methods of this class using RTTI

I have used this:

var
tmpClassType: TRttiType;
tmpContext: TRttiContext;
begin
tmpClassType:=tmpContext.GetType((fClass as TObject).CLassInfo);

but the methods I retrieve are wrong.

I have also tried fField.ClassType but I get the same results.

Anyone, any ideas? Thanks

Comments

  1. Agustin Ortu Sorry, Ididn't understand you wrote that for my question :-) Ok, if you replace TClass with T in the definitions you will have what I mean

    ReplyDelete
  2. You need to constrain T to be class. On the other hand, the constructor parameter becomes irrelevant because already the T generic type has the TypeInfo you need

    I've updated the gist

    ReplyDelete
  3. Agustin Ortu Many thanks for helping me with this :-)

    ReplyDelete

Post a Comment