2
我正在使用MEF的第一個破解,但我似乎無法確定我應該在哪裏創建我的AggregateCatalog
和CompositionContainer
。我發現有很多例子顯示的代碼應該是什麼:MEF + WPF + MVVM:AggregateCatalog應該放在哪裏?
var moduleCatalog = new AggregateCatalog(
new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
new DirectoryCatalog(moduleDir));
var container = new CompositionContainer(moduleCatalog);
container.ComposeParts(this);
但現在我只需要知道在哪裏把它。它應該去:
- 在
App.xaml.cs
- 在
MainWindow.xaml
- 或在我的ViewModels之一。
編輯:應該只是時間稍長用Google搜索,我想我找到了我一直在尋找。
Hosting MEF within application and libraries.