棱镜是否有默认的加载模块的方法? [英] Does prism have a default method of loading modules?

查看:102
本文介绍了棱镜是否有默认的加载模块的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

棱镜中是否有默认的模块加载机制?如果我不在代码或发现中加载我的模块会发生什么?



我尝试了什么:



我仍​​然可以像任何其他类一样调用模块的方法(在引用库之后),那么什么是catch?

Is there a default module loading mechanism in prism? What happens if I don't load my modules in code or by discovery?

What I have tried:

I can still call the module's methods like any other class (after referencing the library), so what's the catch?

推荐答案

如果您能够在构建时引用所需的所有库,那么您不必使用Prism中定义的模块。在这种情况下(如果您的要求很简单)那么使用Prism模块可能会过度。



现在,考虑一下您的应用程序允许您的用户创建/编写自己的插件的情况。您无法事先知道用户将编写哪些插件,因此在构建应用程序时无法引用这些插件。这是Prism模块填补空白的地方,允许您的应用程序通过配置或发现指定其他模块必须在运行时加载和初始化。



我对Prism没有太多经验,但据我所知,它没有默认的加载机制。如果选择使用MEF,则使用声明性属性来定义加载/初始化程序集的内容和方式。在这种情况下,您可以(但不必)实现IModule接口(例如,查看未实现IModule的StockTrader RI示例代码)。如果您不在项目中使用MEF或参考库,则必须实现IModule接口并在XAML中定义模块,配置文件,代码或发现。
If you are able to reference ALL libraries you need at build time then you do not have to use modules as defined in Prism. In this case (and if your requirements are simple) then using Prism modules can be overkill.

Now, consider the situation where your application allows your users to create/write their own plugins. You cannot know in advance what plugins your users will write and therefore you cannot reference these plugins when you build your application. This is where Prism modules fill the gap and allow your application to specify by configuration or discovery what other modules must loaded and initialized at runtime.

I do not have a lot of experience with Prism but from what I recall it does not have a default loading mechanism. If you chose to use MEF then you use declarative attributes to define what and how assemblies are loaded/initialized. In this case, you can, but do not have to, implement the IModule interface (e.g. look at the StockTrader RI sample code which does not implement IModule). If you do not use MEF or reference libraries in your projects then you must implement the IModule interface and define the modules in XAML, a configuration file, code or discovery.


Prism是为企业设计的拥有数千个模块甚至数千个开发人员的应用程序并不少见。棱镜功能(例如,辅助MVVM,GUI,导航,模块之间的通信)对于大规模应用至关重要。



正如我所提到的,对于小型应用,Prism可以绝对是矫枉过正,甚至不必要地使实施复杂化。如果您的应用程序只包含少量视图和/或程序集/模块,并且您选择忽略最佳实践(例如,不要使用MVVM,将业务逻辑添加到文件后面的代码中,请不要使用TDD / BDD等)然后当问题发生时,它们仍然可以管理。
Prism was designed for enterprise applications where it is not uncommon to have thousands of modules and even thousands of developers. Prisms features (e.g. assisting with with MVVM, GUI, navigation, communication between modules) are critical to large scale applications.

As I mentioned, for small applications, Prism can definitely be overkill and even unnecessarily complicate the implementation. If your application consists of only a few views and/or assemblies/modules and you choose to ignore best practices (e.g. do not make use of MVVM, add business logic to the code behind file, do not use TDD/BDD, etc) then when problems occur they are still manageable.


这篇关于棱镜是否有默认的加载模块的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆