IdanB-Forsight
Topic Author
Posts: 12
Joined: 02 Apr 2024, 16:23

Can i check if component is already registered at runtime ?

12 May 2025, 08:27

I have several components that use some custom control.
In every one of them i have on the CTOR a
RegisterComponent of the UserControl type it's depends on.

However if i have common control, it floods my logs with something like:
[NOESIS/E] /OverlayXaml_MessagesScreen;component/AssistantScreen.xaml(48,9): Component 'FSCommonUIControls.NS_SliderButtonUserControl.cSlideButtonUserControlView ()' already registered
I'm in the process of cleaning up the log of any "false-positive" entries it may have.
I can i check at runtime whether I need to registerComponent or not ?
or prevent log entry in the case it's already registered...
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Can i check if component is already registered at runtime ?

12 May 2025, 11:03

You can use Noesis::Factory::IsComponentRegistered(...) for checking if a component is already registered.

Is it not possible for you to have a single function at application start where you register all your components?
 
IdanB-Forsight
Topic Author
Posts: 12
Joined: 02 Apr 2024, 16:23

Re: Can i check if component is already registered at runtime ?

13 May 2025, 10:04

sadly i have different componenet that may (or mat not) be present,
and since each is idependent, i cannot perform it on begining.

Noesis::Factory::IsComponentRegistered isn't template.
How do i get from class name a Noesis::Symbol type ?

Do i have function for it ?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Can i check if component is already registered at runtime ?

13 May 2025, 11:51

If you have the Type, you can use GetTypeId().

If you only have a string, Symbol provides an explicit constructor that accepts a string:
class Symbol
{
public:
    Symbol();
    explicit Symbol(const char* str);
 
IdanB-Forsight
Topic Author
Posts: 12
Joined: 02 Apr 2024, 16:23

Re: Can i check if component is already registered at runtime ?

13 May 2025, 14:13

I have the C++ type.
How do I get from it the Noesis Type class wrapper ?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Can i check if component is already registered at runtime ?

13 May 2025, 18:35

If you have the type you can do:
const Type* type = TypeOf<Button>();
Symbol id = type->GetTypeId();
If you have the instance you can do:
Button* button;
const Type* type = button->GetClassType();
Symbol id = type->GetTypeId();

Who is online

Users browsing this forum: No registered users and 8 guests