不使用MEF等依賴注入技術(shù)的架構(gòu)設(shè)計(jì)
- Views,按功能劃分組織用戶控件文件
- Business,業(yè)務(wù)邏輯
- DAL,數(shù)據(jù)庫ORM中間層
- Infrastructure,基礎(chǔ)架構(gòu)工具
- Log facility
- Json Helper classes
- Design Pattern Helper classes
- Basic Converters
關(guān)于Resource Dictionary
Resource dictionaries are usually defined in the App.xaml. 不過根據(jù)[Ref-2]的方式,我們在架構(gòu)中希望將資源定義在獨(dú)立的模塊中,然后從其他模塊引用它。與[Ref-2]不一樣的是,我們將資源統(tǒng)一包含在Shell項(xiàng)目的App.xaml中,所以我們還需要解決設(shè)計(jì)期資源字典訪問問題。
why views can consume app.xaml even if they’re defined on a separate project
[Ref-1].
Resources defined in the App.xaml become available in the Application.Resources ResourceDictionary of the current Application class (which can be accessed through the Application.Current static property.) Once they’re available there, they can be consumed from within the XAML as static resources. Since modules are loaded into the same application domain as the Shell project, views defined there can access resources as long as they can be found in the corresponding Application.Resources dictionary.
在模塊中定義資源,在其他模塊(Shell)中訪問
[Ref-2]中是任意的UserControl中自定義資源引用,我們需要在Shell中統(tǒng)一引用資源,則在Shell的App.xaml中添加如下代碼:
<pre><ResourceDictionary Source="pack://application:,,,/TradeStation.Infrastructure;component/Resources/Generic.xaml"></ResourceDictionary></pre>
值得注意的是,[Ref-2]說使用“Generic.xaml
”作為名字有“huge benifits”,這個(gè)好像
設(shè)計(jì)期資源引用
在Shell的App.xaml中統(tǒng)一定義資源字典的一個(gè)問題是,VS在設(shè)計(jì)期無法正確的處理。
[Ref-3]涉及到了這個(gè)問題,但是好像沒有太簡單、一次性的解決方案。最終的解決方案還是在每一個(gè)UserControl中的Resources中添加與App.xaml中一樣的一行:
<pre><ResourceDictionary Source="pack://application:,,,/TradeStation.Infrastructure;component/Resources/Generic.xaml"></ResourceDictionary></pre>
題外話:define resource dictionaries that are specific to a certain module
[Ref-1]
參考資料
[1]《How to: define module-specific resource dictionaries in Prism》介紹了利用模塊中的app.xaml來實(shí)現(xiàn)
[2] https://stackoverflow.com/a/8594334/351993
[3] How to use resource dictionary in prism modules at design time?