How to get the type of the elements in a declared TList

后端 未结 1 1026
有刺的猬
有刺的猬 2021-01-25 22:43

I\'d like to know if there is a way to get the type of the elements of a declared, but not instantiated, TList. I can capture the class of an object property like this:

1条回答
  •  隐瞒了意图╮
    2021-01-25 23:06

    As far as I know, RTTI is not flexible enough to give you information about Generic parameters. You will likely have to manually parse the value of MyRTTIProperty.PropertyType.Name (TList) to extract the Generic type name (TMyObject), then use TRttiContext.FindType() to get the RTTI for that type, and then finally you can create instances of its ClassType as needed.

    0 讨论(0)
提交回复
热议问题