Prism4 概述

最近一直在看Prism的资料,希望能和大家一起分享学习的成果。由于我也是第一次碰Prism,所以不足之处还请大家指正。

园子已经有一位前辈牛人写过Prism的系列教程了,我觉得写得不错:

http://www.cnblogs.com/Clingingboy/archive/2009/06/01/prsim_tutorial.html

我没有园子里很多牛人的写作功底,所以文章不会那么细致,主要是抛砖引玉的作用,嘿嘿。

Prism是什么,能做什么

Prism是微软针对WPF,Silverlight以及Windows Phone推出的一套框架,可以帮助开发着轻松解耦自己的项目。Prism也有一些AOP的元素在里面,比如日志记录,但是Prism的主旨还是模块化程序。Prism提供了很多种手段进行注入,模块的动态加载,UI组合,命令系统,MVVM模式扩展等等,下面是Prism的功能比较全面的介绍:

bootstrapper. The class responsible for the initialization of an application built using the Prism Library.

command. A loosely coupled way for you to handle user interface (UI) actions. Commands bind a UI gesture to the logic that performs the action.

composite application. A composite application is composed of a number of discrete and independent modules. These components are integrated together in a host environment to form a single, seamless application.

composite command. A command that has multiple child commands.

container. Provides a layer of abstraction for the creation of objects. Dependency injection containers can reduce the dependency coupling between objects by providing the facility to instantiate instances of classes and manage their lifetime based on the configuration of the container.

DelegateCommand. Allows delegating the commanding handling logic to selected methods instead of requiring a handler in the code-behind. It uses .NET Framework delegates as the method of invoking a target handling method.

EventAggregator. A service that is primarily a container for events that allows publishers and subscribers to be decoupled so they can evolve independently. This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or other modules.

modularity. The ability to create complex applications from discrete functional units named modules. When you develop in a modularized fashion, you structure the application into separate modules that can be individually developed, tested, and deployed by different teams. It also helps you address separation of concerns by keeping a clean separation between the UI and business functionality.

model. Encapsulates the application's business logic and data.

module. A logical unit of separation in the application.

ModuleCatalog. Defines the modules that the end user needs to run the application. The module catalog knows where the modules are located and the module's dependencies.

ModuleManager. The main class that manages the process of validating the module catalog, retrieving modules if they are remote, loading the modules into the application domain, and invoking the module's Initialize method.

module management phases. The phases that lead to a module being initialized. These phases are module discovery, module loading, and module initialization.

multi-targeted code. Code that targets two different platforms with largely the same code-base. This allows binaries targeting two different technologies to be produced while keeping the code as much the same as possible. The technologies that Prism helps you multi-target are Windows Presentation Foundation (WPF) and Silverlight.

navigation. The process by which the application coordinates changes to its UI as a result of the user's interaction with the application, or as a result of internal application state changes.

presenter-first composition. The composition approach where the presenter is logically created first, followed by the view.

on-demand module. A module that is retrieved and initialized only when it is explicitly requested by the application.

region. A named location that you can use to define where a view will appear. Modules can locate and add content to a region in the layout without exact knowledge of how and where the region is visually displayed. This allows the appearance and layout to change without affecting the modules that add the content to the layout.

RegionContext. A technique that can be used to share context between a parent view and child views that are hosted in a region. The RegionContext can be set through code or by using data binding XAML.

RegionManager. The class responsible for maintaining a collection of regions and creating new regions for controls. The RegionManager finds an adapter mapped to a WPF or Silverlight control and associates a new region to that control. The RegionManager also supplies the attached property that can be used for simple region creation from XAML.

Separated Presentation pattern. Pattern used to implement views, which separates presentation and business logic from the UI. Using a separated presentation allows presentation and business logic to be tested independently of the UI, makes it easier to maintain code, and increases re-use opportunities.

shell. The main window of a WPF application or the top-level UserControl of a Silverlight application where the primary UI content is contained.

scoped region. Regions that belong to a particular region scope. The region scope is delimited by a parent view and includes all the child views of the parent view.

service. A service provides functionality to other modules in a loosely coupled way through an interface and is often a singleton.

state-based navigation. Navigation accomplished via state changes to existing controls in the visual tree.

UI composition. The act of building an interface by composing it from discrete views at run time, likely from separate modules.

view. The main unit of UI construction within a composite UI application. The view encapsulates the UI and UI logic that you would like to keep as decoupled as possible from other parts of the application. You can define a view as a user control, data template, or even a custom control.

view-based navigation. Navigation accomplished via the addition or removal of elements from the visual tree.

view-first composition. The composition approach where the view is logically created first, followed by the view model or presenter on which it depends.

view discovery. A way to add, show, or remove views in a region by associating the type of a view with a region name. Whenever a region with that name displays, the registered views will be automatically created and added to the region.

view injection. A way to add, show, or remove views in a region by adding or removing instances of a view to a region. The code interacting with the region does not have direct knowledge of how the region will handle displaying the view.

view model. Encapsulates the presentation logic and state for the view. It is responsible for coordinating the view's interaction with any model classes that are required.

大家可以看到,Prism4 给我们提供了非常多的功能让我们完善自己的应用。

Prism与容器以及其他工具

Prism与容器的关系不得不说一下,Prism是基于依赖注入容器的,目前Prism4提供了两种容器支持,一种是Unity,一种MEF,两种容器的功能相似,但是还是有区别的,Unity可以与EntLib结合,实现AOP功能,我觉得这个很诱人,而MEF嵌入在.net框架里,并且可以自动发现程序集,下载XAP等等功能。在Silverlight和Windows Phone中我更倾向于使用MEF,减小了发布程序集的大小,同时AOP在Silverlight和Windows Phone上的意义不大,当然,也只是我一家之言而已。WPF中我更倾向于使用Unity结合EntLib来做更多的工作。

我将介绍什么

作为一个初学者,很抱歉我也很难给大家提供太多有价值的信息,但是我会尝试给没有接触过Prism的同学一个对Prism完整的印象。

  1. 模块化,模块加载
  2. 依赖注入
  3. 启动与程序初始化
  4. UI组合
  5. 命令系统
  6. 使用MEF容器
  7. 导航

以后是不是还会有其他内容就不得而知了,呵呵。

 

     弄个列表,方便你我,不要问我prism是啥,只要你做wpf or silverlight你就会知道这个东西.

Prism V2之旅(1)-prism基本概览

让你了解下,prism里面的一些基本概念

Prism V2之旅(2)-region容器

了解region容器的使用方法

Prism V2之旅(3)-regionAdapter

region与view容器扩展

Prism V2之旅(4)-attachBehavior

region的行为插件扩展机制

Prism V2之旅(5)-Module

模块化功能介绍

Prism V2之旅(6)-EventAggregator

介绍模块之间的事件交互

prism v2之旅(7)-动态模块加载

该篇主要对silverlight技术的动态加载模块进行介绍

基于wpf的相关设计问题-ViewModel

mvvm很重要,一定得看

基于wpf的相关设计问题-Command的使用

command也很重要,也要看的...

prism behavior图示

画的不好,多包含...

prism模块化问题总结(1)

prism模块化问题总结(2)

这两篇属于胡言乱语,是对于prism框架使用的思考

 

未完,看情况补充.需要用的人可以看看.对于这个框架有什么问题的,也可以提出来

摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第四章的“Key Decisions ”的全部内容,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本节导读:本节只有一节关键决策,在本节中您将会了解进行模块化应用程序开发前要进行何种准备工作。主要包含了如果将划分模块,如果将模块分配到程序集中,以及在Silverlight中的如何将程序集分配到xap文件中去。最后,通过一个实例说明了模块间是如何通过接口(可能是在共享库中的)达到松耦合连接。 阅读全文
posted @  2011-11-30 15:57 bluesky234 阅读(594) |  评论 (7)  编辑
 
摘要: 摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第四章的开头到“Key Decisions ”的全部内容,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本节导读:第四章介绍了模块化应用程序开发所必要的知识和需要注意的内容。而本部分通过讲述模块化应用程序开发所注意的必要概念,包括IModule接口,模块加载过程,模块列表,模块间交流,和依赖注入容器,引出微软所推荐的两款依赖注入框架——Unity和MEF。 阅读全文
posted @  2011-11-23 12:16 bluesky234 阅读(817) |  评论 (6)  编辑
 
摘要: 我已经加班加了一万年,还被迫睡觉到迟到。现在你居然还想让我学新知识?真是自寻死路!工作忙啊忙工作。。干完活来再翻译吧。。。 阅读全文
posted @  2011-11-10 18:51 bluesky234 阅读(38) |  评论 (0)  编辑
 
摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第三章的全部内容,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本章导读:本章主要介绍了为什么 要选择依赖注入容器,并且通过对比,告诉用户如何选择Prism自带的依赖注入容器(也就是Unity和MEF)。而后,通过讲解依赖注入容器的两个基本操作注册和解析,以及自带容器是如何使用这两个操作,来进一步加深对容器的理解。最后,通过对IServiceLocator的讲解(包含内容讲解和使用事项说明)清楚的描述了应该如何更换属于自己的依赖注入容器以及Prism与依赖注入容器间的关系。 阅读全文
posted @  2011-11-08 10:55 bluesky234 阅读(794) |  评论 (1)  编辑
 
摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第二章全部内容,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本章导读: 一、Prism4的启动过程 二、Bootstrapper的基本结构 三、UnityBootstrapper和MefBootstrapper的结构及它们的关系 四、一些示例。 阅读全文
posted @  2011-11-07 10:41 bluesky234 阅读(998) |  评论 (4)  编辑
 
摘要: 因为一些特殊的原因(比如没有存盘,突然停电 etc.),附录H的翻译就这样离我而去了。。跟着里面的内容一做,感觉其实还是很简单的嘛,于是翻译就先这样空着吧。有空了再说。。。下一部分,第二章Prism应用程序的初始化 将来5分钟内更新。。。。我就感觉我翻译的速度是越来越快了。。。当然啦,其实是我事先翻译好的。不过想想第一章我翻译了一天,第二章,我翻译了2个小时。。。这都神马玩意儿! 阅读全文
posted @  2011-11-07 10:37 bluesky234 阅读(43) |  评论 (1)  编辑
 
摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第一章最后一部分,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本节导读:如何将Prism使用到应用程序中 阅读全文
posted @  2011-11-03 23:17 bluesky234 阅读(977) |  评论 (7)  编辑
 
摘要: 摘要: 本文对应Prism 4官方文档(下载地址:http://compositewpf.codeplex.com/releases/view/55580)的第一章关键概念部分,我在此仅翻译其中的内容,并且对翻译的准确性和无二义性不做任何保证。本节导读:Prism中的关键概念,本人特别推荐和我一样的新人们仔细看本节的原文内容(因为怕我翻译有二义)。 阅读全文
posted @  2011-11-02 22:38 bluesky234 阅读(1229) |  评论 (7)  编辑
 
摘要: 羞愧啊,居然好多字都不认识,好多东西都没认全。。。人间之悲剧就是看完这一些后我认为我可以重新回去把软件工程的书重头到尾重新看一遍了。咳,大学白读了啊,对不起老师,对不起党,对不起父母,对不起自己啊!!!不过,感觉原版写的确实非常好啊,对我等小白来说,还是非常实分之有用的。本来我不喜欢看这种东西的人居然翻译了一次后,居然感觉他居然说的不是空话。。。纳尼,微软说的不是空话?那难道我以前做的东西都是白做啦。。掩面泪奔中,争取晚上更新“第四部分,Prism的关键概念”!咳,难得我又能把这东西当小说看了,怀念ING。咳,下面有错别字就效应着看吧,反正我已经说都不会话了。。您可以在以下位置找到原文:ht. 阅读全文
posted @  2011-11-02 17:01 bluesky234 阅读(180) |  评论 (0)  编辑
 
摘要: Prism4的文档居然没有简体中文版本。让我看的着实蛋疼不以,找时间翻译一下,与大家共享吧。本人不保证翻译的正确性,或者没有二义性。因为时间有限,就只好一点一点翻译,翻译多少写多少吧。改个标题,因为这个并不是从第一章介绍的第一段开始翻译的,前面几段实在是。。算了不翻了本部分主要介绍如何安装Prism以及Prism的更新内容,第一章 第三部分则是介绍Prism的设计目标和重要概念。设计目标已经翻译完成啦!您可以在以下位置找到原文:http://compositewpf.codeplex.com/releases/view/555801. 准备开始Prism:1.1 前提:使用Prism需要您拥有 阅读全文
posted @  2011-11-02 10:24 bluesky234 阅读(340) |  评论 (0)  编辑

你可能感兴趣的:(r)