Hi , I try to find out the indextype of an indexed parameter with RTTI.

Hi , I try to find out the indextype of an indexed parameter with RTTI. 
For    property xx[a:String]: ....    I would like to find out "String". 

Any hint? 

Bernd

Comments

  1. You could use:
    TRttiContext.Create.GetType(D.ClassType).GetIndexedProperty('Data').ToString

    Which results in something like:

    'property Data[AIndex: string]: Integer'

    To dig deeper, you could also use ReadMethod.GetParameters[0].ParamType

    ReplyDelete
  2. You have to use the parameters of the TRttiIndexedProperty.ReadMethod and/or TRttiIndexedProperty.WriteMethod.
    This is also what TRttiIndexedProperty.ToString does.

    ReplyDelete
  3. We have developed an easier and more powerful RTTI library for Delphi. It makes checking this type of stuff really piece of cake.
    We plan to release it as free library in about a month or so as part of our free Mitov Runtime library.
    If you are interested, please contact me on Skype - bmitov or over e-mail mitov@mitov.com and I will send you install.

    ReplyDelete
  4. Boian Mitov Unless you build your own compiler to generate RTTI there is not much more than enhance the API of the enhanded RTTI (the things from System.Rtti.pas) because some things are just not there.
    Like the types of the indixes of an indexed property can only taken from the getter/setter (that is why their RTTI gets included no matter what visibility you have set for methods).
    Anyway I would be interested to see what you did about the RTTI.

    ReplyDelete
  5. Stefan Glienke
    You would be surprised ;-)

    ReplyDelete

Post a Comment