Modules

Modules are packages of functionality, usually composed of views, services, data models and more. Modules can encapsulate common application infrastructure or service that can be reused across multiple applications. The module needs to have a central class for the initialization and integration process. That class must implement the IModule interface. Implements this class identify the package as a module.

Example of a Module in C#:

public class MyModuleDepedencyA : IModule
    {
        private IRegionManager regionManager;
        IUnityContainer container;
        
        public void Initialize()
        {
            container.RegisterInstance<IMyService>(new MyServiceImp());
            this.RegisterViewsAndServices();
            this.regionManager.RegisterViewWithRegion("ModuleA", () => this.container.Resolve<IModuleAModel>().View);
        }
        
        ...
}

For a general description on how it works check this https://prismlibrary.com/docs/modules.html

Modules in Typescript

An interface similar to IModule has been created in the Framework called IPModule:

The interface contains an initialize method used to register types or services that the module implements. In the example above the code registers a service called IMyService, also it registers a view in the ModuleA region.

One important thing about the Module, the constructor receives an instance of the container to resolve and register new types, and an instance of the regionManager to register the new views.

Last updated

Was this helpful?