Get type of ObservableCollection from Basecomponent
Hi Noesis Devs!
I've been struggling with getting the templated type of a ObservableCollection from a BaseComponent. I've managed to get ObservableCollection from conversion with "DynamicPtrCast". But am now halted as i need to add the correct class type into the ObservableCollection, so that i can set the values of the reflected properties of that certain class through ImGui.
TLDR;
Want the correct T type to insert into a ObservableCollection, but don't know the T type.
I've been struggling with getting the templated type of a ObservableCollection from a BaseComponent. I've managed to get ObservableCollection from conversion with "DynamicPtrCast". But am now halted as i need to add the correct class type into the ObservableCollection, so that i can set the values of the reflected properties of that certain class through ImGui.
TLDR;
Want the correct T type to insert into a ObservableCollection, but don't know the T type.
Re: Get type of ObservableCollection from Basecomponent
Right now there is no way to get that information. I assume when you mention using DynamicPtrCast you mean BaseObservableCollection instead of ObservableCollection right?
I need to understand more about your scenario to help you. Do you want to box the elements and add them using the BaseCollection API?
I need to understand more about your scenario to help you. Do you want to box the elements and add them using the BaseCollection API?
Re: Get type of ObservableCollection from Basecomponent
Well ATM i get the base type of my class which is based on BaseComponent, so " ObservableCollection < iDataModel > ". Which allows me to add and remove but not add the 'specific' class. Which doesn't allow me to have the correct properties.
So Yes, i want to box a BaseComponent into T of ObservableCollection, so that i can add them using the API.
For more context, i'm making a recursive property setter for Noesis with ImGui. This is made for other developers to test Noesis Layouts without needing backend info
So Yes, i want to box a BaseComponent into T of ObservableCollection, so that i can add them using the API.
For more context, i'm making a recursive property setter for Noesis with ImGui. This is made for other developers to test Noesis Layouts without needing backend info
Re: Get type of ObservableCollection from Basecomponent
"Finally after what feels like forever there is light at the end of the tunnel. It is however a lamp and not the exit"
We managed to make it work using the CPP rob function, which basically is a void function ptr to a member of a class you can specify. If you find another solution please do share, as more solutions means better results.
Thank you nonetheless for taking the time to help me.
We managed to make it work using the CPP rob function, which basically is a void function ptr to a member of a class you can specify. If you find another solution please do share, as more solutions means better results.
Thank you nonetheless for taking the time to help me.
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Get type of ObservableCollection from Basecomponent
If you don't know the right T then I guess the collection will be passed to you as a BaseComponent.Want the correct T type to insert into a ObservableCollection, but don't know the T type.
And the same happens for the item you want to add, if you don't know the exact type, it will be just boxed or a BaseComponent inherited class.
My suggestion then is to process everything through the base classes:
Code: Select all
void AddItem(BaseComponent* collection, BaseComponent* item)
{
BaseCollection* collection_ = (BaseCollection*)collection; // or use DynamicCast if you don't know for sure it is a BaseCollection
collection_->AddComponent(item);
}Who is online
Users browsing this forum: No registered users and 5 guests