当前位置:网站首页>Introduction to prism framework - Modular introduction
Introduction to prism framework - Modular introduction
2022-06-12 01:30:00 【Tsim Sha Tsui Duan Kun 415】
In actual work, we will divide the functions into multiple modules for development
- Onion structure —— Separation is for better union
In order to make the software easy to maintain , test , And flexible enough , So there is the onion structure , It is a good choice to develop any software
Code dependencies are from the outside in , The code in the inner ring should not know anything about the outer ring .
The outer layer depends on the inner layer , The inner layer has no perception of the outer layer
2008 year Jeffrey Palermo Proposed onion architecture
Key principles of onion Architecture :
- Build applications around independent object models
- The inner layer defines the interface , The outer layer implements the interface
- The direction of dependence points to the center of the circle
- All application code can be compiled and run independently of the infrastructure
—— Jeffrey Palermo 2008, The Onion Architecture: part 3

prism Examples of modular functions
Create two new projects , Then attribute - change WPF The application is a class library

Add... To the two class libraries respectively Views Folder - Then add a paragraph of text to show

viewa and viewb

A program is recognized as a module because it has certain characteristics
Then create a new class ModuleAProfile
And then manage nuget Add... To the package Prism.Dryloc My bag
Turn it out and implement it in the class IModule This interface
( Then we realized that we can not implement this method , Then delete the method )
public class MouleAProfile : IModule
{
public void OnInitialized(IContainerProvider containerProvider)
{
}
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<viewA>();// Register here ViewA, Remember to add views Declaration space for
}
}And then the same thing ,ModuleB It's the same operation
Add... To the solution ModuleA and ModuleB Project references for ![]()
Then add the method
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
moduleCatalog.AddModule<ModuleAProfile>();
moduleCatalog.AddModule<ModuleBProfile>();
base.ConfigureModuleCatalog(moduleCatalog);
}You can achieve cross region search

But this is a strong reference method , There's another way
First, remove the strong reference to , Then delete the calling and reference projects
find ModuleA and ModuleB Of bin/Debug Inside dll Suffix program
Create a new folder in the same location as the folder in the main application , It contains the required assemblies 
Then set the folder name
Used to find
public class Xin
{
public partial class App : PrismApplication
{
protected override Window CreateShell()
{
return Container.Resolve<Mainview>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
}
protected override IModuleCatalog CreateModuleCatalog()
{// You can directly return the specified module address In this way, the coupling relationship is greatly reduced
return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
}
}
}return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
When this method is started, it will be loaded when it meets the contract


7-Modules-AppConfig
7-Modules-LoadManual
7-Modules-Xaml
Are used to load modular
Github Of prism Module call cases
The general method is : Set up a way to find modularity - Then define a required module - Hit a corresponding container - After startup, the automatic matching search is loaded
边栏推荐
- Some suggestions on writing code to reproduce the paper!
- [project training] JWT
- 博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现
- Simulated 100 questions and simulated examination for safety management personnel of metal and nonmetal mines (small open pit quarries) in 2022
- How much is the child's critical illness insurance coverage appropriate? Which product is better now
- Simulated 100 questions and simulated examination for safety management personnel of metal and nonmetal mines (small open pit quarries) in 2022
- Online Fox game server - room configuration wizard - component attribute and basic configuration assignment
- Perceptron from 0 to 1
- Unity顶点动画的阴影实现
- Forecast report on market demand and future prospect of cvtf industry of China's continuously variable transmission oil
猜你喜欢

打造Flutter高性能富文本编辑器——渲染篇

The CSV used for JMeter performance test is bullshit

马尔可夫网络 与 条件随机场

博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现

Esp8266wifi development board collects temperature and humidity data and uploads them to the Internet of things platform

JMeter operation process that can be understood at a glance

Entity class dto to VO is converted through plug-in

【项目实训】校验注解

中创专利|中国5G标准必要专利达1.8万项,尊重知识产权,共建知识产权强国
![[project training] wechat official account template message push](/img/1f/2fe272e2d2a5e3573299c063e870e5.png)
[project training] wechat official account template message push
随机推荐
只会基础的功能测试的我,被炒鱿鱼了····
2022年重氮化工艺考试题库模拟考试平台操作
【项目实训】校验注解
Interviewer: do you understand redis' shared object pool?
Intel trimbert: tailor Bert for trade-offs
Global and Chinese lutetium oxide powder industry investigation and analysis and Investment Strategy Research Report 2022-2028
[project training] wechat official account template message push
The 14th five year plan and investment feasibility study report of global and Chinese hydraulic ester base oil industry 2022 ~ 2028
网狐游戏服务器-房间配置向导-组件属性与基本配置赋值
A knowledge map (super dry goods, recommended collection!)
Colorize Voronoi Diagram Template
Forecast report on industry operation and development strategy of global and Chinese suspension control station industry 2022-2028
What is the digital twin of Yixin Huachen and what is its application value?
Yixin Huachen talks about how to do a good job in customer master data management
市场监管总局、国家网信办:开展数据安全管理认证工作
【科普视频】到底什么是透镜天线?
Unity顶点动画的阴影实现
Learn to crawl steadily 07 - detailed explanation of how to use XPath
感知机从0到1
Operation of simulated examination platform of diazotization process examination question bank in 2022