Jump to content
Sign in to follow this  
Tommi Prami

Update Interface property value with RTTI

Recommended Posts

Did not find example for this.

 

Basically I need some kind of methods that are

UpdatePropertyIfAvaibalble(const AInterface interface; const APropertyName: string; const AValue: string);

 

UpdatePropertyIfAvaibalble(IMyInterfaceThingy, 'Id', 'IDSTRINGVALUE');

 

And overloads for different data types. Datatype is known. Cool if would check the datatype of property tough, is it compatible...

Why I need this is that there is XML interface which does not have inheritance, so most nodes have all the same properties but not inherited from same interface so can't use that (woulöd have been too easy :D).

So using RTTI would help a ton. Never done that with interfaces so not sure where to start.

 

-Tee-

Share this post


Link to post

There is no RTTI available for interface properties - you have to refer to them via the setter method name.

And even that only works if the interface has {$M+} or inherits from IInvokable.

Edited by Stefan Glienke

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×