pingping
Topic Author
Posts: 5
Joined: 25 Jul 2020, 00:59

Accessing List of reflected properties added with NSProp

23 Jun 2021, 15:36

Hello,

I am trying to write a generic behavior and I would need to go trough in reflected properties of ViewModel of attached control.
NS_IMPLEMENT_REFLECTION(PersonViewModel)
{
NSProp("Name", &PersonViewModel::GetName);
NSProp("Age", &PersonViewModel::GetAge);
}
In this example, how can I get "Name" and "Age" property names and how can I query the value of this properties.
I wrote the similar idea with C# and it is working. When I tried the same idea with c++ BaseComponent::GetDataContext()::GetClassType(), (in this case DataContext is PersonViewModel)I do not see these properties that I added with NsProp.
 
pingping
Topic Author
Posts: 5
Joined: 25 Jul 2020, 00:59

Re: Accessing List of reflected properties added with NSProp

23 Jun 2021, 16:08

Ok, What I was doing was correct. GetClassType() is indeed giving properties that are added with NsProp.
My mistake was calling TypeClass::GetProperty(uint32_t index) with Noesis::Symbol. Since it is not explicit method it was accepting the parameter.
I should be calling TypeClass::FindProperty(Symbol name).
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Accessing List of reflected properties added with NSProp

25 Jun 2021, 19:40

Yes, as you discovered, TypeClass exposes everything declared using macros. Great to know you solved the issue.

Who is online

Users browsing this forum: Google [Bot] and 64 guests