首页 技术 正文
技术 2022年11月17日
0 收藏 792 点赞 3,424 浏览 1280 个字

StockTrader RI 代码分析也有一段时间了

刚从codeplex获取到源代码的时候,看得一头雾水,不知所云(因为之前没做过wpf的项目,看文档也静不下那心来看)

后来就想了个笨办法,模拟项目实现一个新的demo项目,从布局,加载组件入手!

这确实是一个好的办法,三下五除二,整个StockTrader RI的结构就清晰明了

首先项目需要启动,注入模块:

使用的是Mef实现

其代码在/StockTraderRI/StockTraderRIBootstrapper.cs

主要关注ConfigureAggregateCatalog方法的代码

 protected override void ConfigureAggregateCatalog()
{
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(StockTraderRIBootstrapper).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(StockTraderRICommands).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(MarketModule).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(PositionModule).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(WatchModule).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(NewsModule).Assembly));
}

其次,关注Shell.xaml的布局

布局部分就得参考Prism4.chm文档的 Chapter 7: Composing the User Interface

借用文档的布局划分图

prism4 StockTrader RI 项目分析一些体会

region的定义在 StockTraderRI.Infrastructure/RegionNames.cs

刚开始我没办法理解prism的各模块是如何组合,后来看了msdn 及博客园的文章,对mef有一定了解

就明白了,参考文章http://www.cnblogs.com/beniao/category/252120.html

剩下的就是靠个人阅读代码理解了.在我看来,通过shell显示总体布局,然后Modules实现具体的模块功能,使各模块解耦合

然后再具体剖析,一些有意思的实现,比如 TabItem的实现,ActionContent代码实现该位置的region激活(参考OrdersController,ShowOrdersView)

发现项目虽小,五脏俱全,了解了这个项目,对wpf就算入门了

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,299