Reputation: 65
Good day!
UPDATE
I don’t understand how to access the functionality of the Prism module from the class using the module logic.
Questions:
How do I get access to the implementation of the IServiceA functionality (defined in the module) in PageAViewModel, which I forget to do?
How can I manage the life of ModuleA / ServiceA if I want to use this functionality on a number of different countries, without loading the module every time (scenario - I call ModuleA / ServiceA when loading an application, use it on PageA / PageB / PageC, after using it I unload it) .
Thank you all for any answers! Have a nice day! /Sorry for google translate/
Upvotes: 0
Views: 156
Reputation: 10863
The modules of a prism application are for modularizing the code base. They have nothing to do with views or view models, but rather splitting the application up into components that can be independently developed and tested and replaced. How you split your application is up to you.
Probably you should review the documentation chapter about modularity...
Edit: about the concret questions:
How do I get access to the implementation of the IServiceA functionality (defined in the module) in PageAViewModel, which I forget to do?
You create a constructor parameter of type IService
and prism will provide you with the registered implementation:
internal class PageAViewModel
{
public PageAViewModel( IService service )
{
service.DoStuff();
}
}
How can I manage the life of ModuleA / ServiceA if I want to use this functionality on a number of different countries, without loading the module every time
You cannot and need not manage the lifetime of ModuleA
, prism takes care of that. As for, ServiceA
you chose a lifetime when registering:
containerRegistry.Register<IService, ServiceA>()
creates a new service instance for each pagecontainerRegistry.RegisterSingleton<IService, ServiceA>()
create a single service instance for all the pagesUpvotes: 1