Page 1 of 1

Accessing List of reflected properties added with NSProp

Posted: 23 Jun 2021, 15:36
by pingping
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.

Re: Accessing List of reflected properties added with NSProp

Posted: 23 Jun 2021, 16:08
by pingping
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).

Re: Accessing List of reflected properties added with NSProp

Posted: 25 Jun 2021, 19:40
by jsantos
Yes, as you discovered, TypeClass exposes everything declared using macros. Great to know you solved the issue.