[Prism] Composite Application Guidance for WPF (2) -- Composite Application Library (CAL)
Zhou yinhui
1, OneComposite ApplicationBasic Components
Composite Application Library(Cal)Composite Application GuidanceIs the most important componentComposite ApplicationThe most basic components and services.
Take a look at the figure below
OneComposite ApplicationIt is usually composed of these parts (at the same time, Cal provides us with these basic components)
Shell: ApplicationProgramTop-level window, itsHostDifferentUIComponents (usuallyView),ShellIt does not know what content it contains. Generally, it has very limited functions, while the vast majority of other functions are composed of variousModuleTo provide
Shell presenter:ShellPresentation Layer logic, andMVPInPresenterThe same meaning, which makesShellEasy to test and maintain
Region: It is equivalent to a placeholderHostVisualization elements (which are placed inViewAnd passRegion ManagerTo access)
Module:ViewA collection of data models, business logic, services, and so on, which is also known as the "module", which is easy to be developed, tested, and deployed independently, normally, we allow different team members or even different teams to take charge of different modules, and then these modules are finally integrated into a complete application.
View: "View", andMVPInViewMeaning the same.
Service: The application or module exposes some "services" for sharing. These services are located and loaded by something that becomes a "service container" (inCalWhich isUnity container)
2, CreateCalOfComposite WPF Application
If the application is complex, we generally divide the application into different modules, and then use anotherShell projectTo organize these modules, let's see how to useCalTo achieve this.
Let's see:
DefineShell:
ShellProvides basic layout for the main interface of the program.RegionTo define (or to placeholder), and other modules canRegionInjection view (ViewOr other visual elements ). Generally,ShellIt also contains the basic style of some applications (Style) To provide a uniform style for the application.
Shell,View,RegionFor more information, see
CreateBootstrapper
Each application has its own uniqueBootstrapper(It inherits fromUnitybootstrapper) To define a policy for how to enumerate its modules (for example, to enumerate each module by static reference, or to configure each module by using a configuration file.CabOfProfilecatalog. xmlFile)
Generally,UnitybootstrapperAllCalBasic services, but we can disable or replace these services to customize the services that are more suitable for our applications.Bootstrapper.
In addition,BootstrapperProvides the log function, which uses. Net tracewriterBut we can alsoBootstrapperTo customize your own logs.
For more information, see
CreateModule
In terms of syntax, we need to implementImoduleInterface to createModule. In addition,ModuleIn this moduleViewInjectShellOr other modulesRegion.
InComposite Application Guidance for WPFWe can see moreMVPMode to createModule. AboutComposite Application Guidance for WPFInMVPMode.Article.
DeploymentComposite WPF Application
basically deploy common WPF desktop applications ( installer , clickonce ), but sometimes there are some new problems. Because we can use loose methods to organize various modules (such as using configuration files), there is no direct reference relationship between modules, as a result, some packaging tools cannot automatically find the associated modules for packaging. For this reason, Cal provides some tools and technologies to solve these problems.