mef

WPF MEF + Prism initial Region loading

╄→гoц情女王★ 提交于 2019-12-22 10:56:46
问题 I have written an MVVM app in WPF using MEF and Prism with three different regions. Code is across two modules, being discovered in the App.Config. I have all the navigation commands and structure working perfectly fine, but the one thing I am confused on is how to set the initial Views loaded into each region at app startup as there seems to be nowhere I can do this. Furthermore if I add something to the end of the MainViewModel constructor to explicitly navigate to screen set A, something

Use classes from another MEF assembly without referencing to it

最后都变了- 提交于 2019-12-22 10:06:49
问题 I have 2 MEF components. Let it be component A and component B. What I need is to be able to access a class from component B in component A without referencing to it. Then I would like to instantiate object of the class manually. Currently I see MEF allows instantiating an object automatically using [Import]. It uses interface which requires to be referenced to. Can I use data types from another assemblies without referencing to it? Is there such mechanism supported by MEF? 回答1: There are a

MEF: difference between GetExportedValue and SatisfyImports

假装没事ソ 提交于 2019-12-22 08:34:50
问题 We're using MEF (.NET 4, can't use 4.5 at the moment) in a MVVM application. Everything was fine until we needed to create models on the fly, for instance editable rows of a table. I didn't want to run into memory leaks, I found this article http://pglazkov.blogspot.ch/2011/04/mvvm-with-mef-viewmodelfactory.html and I discovered an unexpected behavior that I would like to understand. This is an Item added to the Shell.Items observable collection: [PartCreationPolicy(CreationPolicy.NonShared)]

How to release a shared instance from a MEF container

白昼怎懂夜的黑 提交于 2019-12-22 06:16:25
问题 I am trying to release a shared instance or singleton value. Does anyone know how to do this? Do I have to refresh the catalog? I'm learning MEF so please help. Example of class [Export] public class Foo { public RandomProperty {get;set;} [ImportConstructor] public Foo() {} } You can create it with something like this: var fooSingleton = ServiceLocator.GetInstance(typeof(Foo)); All fine and good, but ideally I would like to do something like this Container.Replace(oldFoo, newFoo); So when I

Decoupling the view, presentation and ASP.NET Web Forms

风格不统一 提交于 2019-12-22 05:59:21
问题 I have an ASP.NET Web Forms page which the presenter needs to populate with controls. This interaction is somewhat sensitive to the page-life cycle and I was wondering if there's a trick to it, that I don't know about. I wanna be practical about the whole thing but not compromise testability. Currently I have this: public interface ISomeContract { void InstantiateIn(System.Web.UI.Control container); } This contract has a dependency on System.Web.UI.Control and I need that to be able to do

Decoupling the view, presentation and ASP.NET Web Forms

家住魔仙堡 提交于 2019-12-22 05:59:11
问题 I have an ASP.NET Web Forms page which the presenter needs to populate with controls. This interaction is somewhat sensitive to the page-life cycle and I was wondering if there's a trick to it, that I don't know about. I wanna be practical about the whole thing but not compromise testability. Currently I have this: public interface ISomeContract { void InstantiateIn(System.Web.UI.Control container); } This contract has a dependency on System.Web.UI.Control and I need that to be able to do

Locating Exports for Objects Created After ComposeParts Called

耗尽温柔 提交于 2019-12-21 18:41:06
问题 I've got a very simple app with a single export and multiple imports for the same type. After I call ComposeParts I can see that the import worked in the same class where I called ComposeParts from - the MyService property has been hooked up. The problem is that I have another UserControl that needs access to MyService and the property isn't set - it's in the same package etc. but it's not instatiated at the time I call ComposeParts. If I make my CompositionContainer public / static and call

Caliburn Micro -> Composing Views from multiple Views/UserControls/CustomControls

最后都变了- 提交于 2019-12-21 05:54:28
问题 How is it possible to re-use and compose parts in CM managed windows? I have found posts regarding using two UserControls to bind to the same ViewModel, but not so much if I want to have multiple views and viewmodels all composed in the same window. (a viewmodel for each view composed into a "master view") The first part of my question would be how to break up components for re-use? If I have two areas of a window where one is a datagrid and another is a details view with labels and text

Loading a prism module view from the shell, using MEF

南楼画角 提交于 2019-12-21 05:35:09
问题 I have a shell project which is loading modules in my bootstrapper into a tab control in my shell's main view. I have just implemented a close button on my tab items which now poses the question of how do I reload module views from the shell? Tried using moduleManager.LoadModule("ModuleA"); but this only works when the module is first loaded. When I call the above it loads and initializes the module, displaying the view. If I then close the view again, the 2nd time I try this it doesn't

MEF and unit testing with NUnit

那年仲夏 提交于 2019-12-21 05:31:25
问题 A few weeks ago I jumped on the MEF (ComponentModel) bandwagon, and am now using it for a lot of my plugins and also shared libraries. Overall, it's been great aside from the frequent mistakes on my part, which result in frustrating debugging sessions. Anyhow, my app has been running great, but my MEF-related code changes have caused my automated builds to fail. Most of my unit tests were failing simply because the modules I was testing were dependent upon other modules that needed to be