Agenda
• Is there a modular application? • Initializing modules
What is a module? It allowed me
to translate the first paragraph of chapter 4 of Prism 4th ebook Here it is.
modular application is an application divided into a set of functional units (called modules) that can be integrated into one larger application.
module is a kind of container parts funkcjonalnościcałej applications and typically represents a set of interrelated issues. Such a module may include elements describing zbirór part of business logic, part of the application infrastructure such as sites responsible for the login or user authentication. The modules are independent relative to each other, but they can communicate with each other based on a broadcast mechanism.
modular application can help you with the development, testing, implementation or expansion.
is how to divide an application depends only on you. This may be due to the breakdown of the relevant business topics such as procurement module, the module invoices. It may also be due to the breakdown of application architecture such as data access module, the module UI module utility. Take advantage of both worlds and have the application division of the technical modules and business modules. From my own experience I would not recommend creating separate modules for each view or couples views (eg view the list of users with a view of the details of the user). With the development of applications, increase the number of such modules, and your work with Visual Studio for example, 50 modules (projects) will become a nightmare.
initialization modules
whole process of loading the module starts with a function call:
_moduleManager.LoadModule (CalendarModule ");
The figure shows almost everything you need to know is:
Register module in modules directory
For Silverlight'a Prism provides two ways to register the modules (modules are recorded in bootstraperze)
The first is the initialization of a module directly in the code protected override
IModuleCatalog GetModuleCatalog ()
{var
ModuleCatalog moduleCatalog = new ();
calendarModuleInfo var = new ModuleInfo
{
ModuleName = "CalendarModule"
ModuleType = "MVVMBasic.CalendarModule.Module, MVVMBasic.CalendarModule, Version = 1.0.0.0" ,
Ref = "MVVMBasic.CalendarModule.xap"
InitializationMode = InitializationMode.WhenAvailable
};
moduleCatalog.AddModule (waitWindowModuleInfo);
moduleCatalog return;}
second way is to load modules to a directory on the XAML file
private const string
ModuleCatalogUri = "/ MVVMBasic; component / ModulesCatalog.xaml"
protected override IModuleCatalog CreateModuleCatalog () {
Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml return (new Uri (ModuleCatalogUri,
UriKind.Relative));}
Where XAML file is:
\u0026lt;modularity: ModuleCatalog xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: sys = "clr-namespace: System; assembly = mscorlib" xmlns
: modularity = "clr-namespace: Microsoft.Practices.Prism. modularity; assembly = Microsoft.Practices.Prism ">
\u0026lt;Modularity:ModuleInfoGroup Ref="MVVMBasic.CalendarModule.xap" InitializationMode="WhenAvailable">
\u0026lt;Modularity:ModuleInfo ModuleName="MVVMBasic.CalendarModule" ModuleType = "MVVMBasic.CalendarModule.Module, MVVMBasic.CalendarModule, Version=1.0.0.0",/>
\u0026lt;/ modularity: ModuleInfoGroup>
\u0026lt;/ modularity: ModuleCatalog>
Finding modules
This step relates to WPF. The programmer must indicate the location of the directory that contains modules.
Get the module you are interested in the proper location
for Silverlight applications, in this step is taken the module with the appropriate network location (directory / ClientBin in the virtual directory of our hosted applications), and transferred and loaded into memory on the client side. Since
download the module from the server to download further data packets (which can be large), we can determine how the module is to be levied. He tells us about this property InitializationMode, which takes the values:
• InitializationMode.OnDemand - get a module on demand,
• InitializationMode.WhenAvailable - get a module in the background in a separate thread.
Initialize module
After downloading the module, followed by its initialization, which aims to integrate this module with your application. Initialization occurs by looking at the downloaded module type specified in the modules folder as ModuleType .
is the class that implements the interface IModule .
namespace MVVMBasic.CalendarModule
{public class Module: IModule
{# region init
private readonly IRegionManager _regionManager;
readonly IUnityContainer _container;
readonly IEventAggregator _eventAggregator;
public Module (IRegionManager regionManager, IUnityContainer container,
IEventAggregator eventAggregator)
{
_regionManager = regionManager;
_container = container;
_eventAggregator = eventAggregator;
} # endregion # region
IModule
Members public void Initialize () {
/ / register new types of container
_container.RegisterType \u0026lt;ICalendarView, CalendarView> ();
_container.RegisterType \u0026lt;ICalendarViewModel, CalendarViewModel> ();
/ / Inform manager of regions, in which the region displays a view
_regionManager.RegisterViewWithRegion (CalendarView ", () => new CalendarView ());
/ / Tell all about the listening end of the module initialization
_eventAggregator.GetEvent \u0026lt;ViewInitializedEvent> (.) Publish (" CalendarModule ");}
} # endregion}
stark minimum to initialize the module is to implement the Initialize method . However, our module consists of a set of views that should be recorded in appropriate containers, managers.
0 comments:
Post a Comment