zoukankan      html  css  js  c++  java
  • prism4 StockTrader RI 项目分析一些体会

    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

    借用文档的布局划分图

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

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

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

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

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

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

  • 相关阅读:
    POJ 1466 Girls and Boys 黑白染色 + 二分匹配 (最大独立集) 好题
    POJ2226 Muddy Fields 二分匹配 最小顶点覆盖 好题
    POJ 2195 Going Home 最小费用流 裸题
    POJ 3368 Frequent values RMQ 训练指南 好题
    POJ 3187 杨辉三角+枚举排列 好题
    POJ 2393 贪心 简单题
    系统监控
    系统的初始化和服务
    vi与vim
    正文处理命令及tar命令
  • 原文地址:https://www.cnblogs.com/wyxy2005/p/3359729.html
Copyright © 2011-2022 走看看