#1 2024-04-12 11:51:03

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

TRttiCustomProp - retrieve Delphi rtti information

When I use mormot.core.rtti and retrieve the properties of a class, each of them is represented by a "TRttiCustomProp" record. Is there a way to access the original Delphi rtti context information?

Reason: I want to check attributes assigned to that specific property. Another way to retrieve them would be appreciated as well ;-)

Regards,
Daniel

Offline

#2 2024-04-12 13:56:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: TRttiCustomProp - retrieve Delphi rtti information

You have access to the TypeInfo() pointer as in the Value^.Info: PRttiInfo field.

In fact, in mORMot units, the PRttiInfo type is just a wrapper around the raw TypeInfo() RTTI pointer.

Offline

#3 2024-04-13 10:40:59

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Re: TRttiCustomProp - retrieve Delphi rtti information

That's what I thought, but for some reason I could not get a valid return on my attributes. However, I just had a thought about that - will check tomorrow.

Offline

#4 2024-04-13 14:20:07

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Re: TRttiCustomProp - retrieve Delphi rtti information

ab wrote:

You have access to the TypeInfo() pointer as in the Value^.Info: PRttiInfo field.

Tried it again, but this gives me the TypeInfo of the property value type.For: Sample writing

Ctxt.GetType(Entry.Value.Info)

for

[MyAttribute]
property XYZ: Integer read FXYZ write FXYZ

it would return the type info for "Integer", which doesn't help. If I would

Ctxt.GetType(Entry.Prop)

, I do get back the correct Delphi Rtti object (of class TRttiInstancePropertyClassic), however, something is off, as I do not get the list of attributes attached to that property.

Strange...
Daniel

Last edited by sakura (2024-04-13 14:21:25)

Offline

#5 2024-04-15 08:01:00

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: TRttiCustomProp - retrieve Delphi rtti information

Have you checked using delphi own's rtti mechanisms , aka TRttiContext ?

Offline

#6 2024-04-15 08:07:02

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Re: TRttiCustomProp - retrieve Delphi rtti information

Sure, but I am needing and using the mormot rtti in that place and simply try to get that attribute list for special cases.

Offline

Board footer

Powered by FluxBB