Krzysztof had a question on StackOverflow around doing MVP triads wtith MEF. He came up with a way to do it that he wasn't happy with and which I told him was pretty hacky 🙂 After chatting with Krzysztof I took a shot and came up with something which looks pretty clean.
So what's going on here?
Shell gets injected with Presenter. Presenter gets injected with View and Model. Everything here is singletons, but doesn't have to be.
The difference between our two examples is that the Presenter is getting injected into the shell rather than the View. If the Presenter is creating the View then you can't just grab the View first (as he was doing), or the Presenter will not get created. Well you can do it, but you end up hacking it to bits. Cleaner is to just inject the Presenter and have it expose an IView. We did this in Prism and it worked quite well.
Yes, yes this looks DI containerish. You can use MEF for simple DI stuff (as Krz is doing), but as you get to more complex systems, the experience won't be optimal.