I’ve got two questions (of which at least one is regarding RTTI in D2010 and dynamic instancing)
- I was reading what appears to be the foils for a conference talk by Barry Kelly, and found on p. 13 something that looked really interesting:
TRTTIConstructor.Invoke. In an adjacent bullet point, one finds “Dynamically construct instances without needing virtual constructors and metaclasses”. This seems like a great feature (and exactly what I need, btw)! However, when I look in the D2010 docs (ms-help://embarcadero.rs2010/vcl/Rtti.html), I can’t find it. Did it get revoked? - What is the minimal way of creating an instance of a class, provided the class name is stored in a string?
I think that functionality has been absorbed into TRttiMethod. It has IsConstructor, IsDestructor and IsClassMethod properties so that it can be used for “special” types of methods as well as normal ones.
As for question 2, try something like this:
This finds the highest constructor called
Createthat takes no parameters. You can modify it to look for other constructors with other signatures, if you know what you’re looking for. Then just callInvokeon the result.