0

I'm using MEF in my Silverlight application. My code would be a lot cleaner if there were a way to "import" an instance imperatively in code (i.e. without using the Import attribute). I've been using MEF for quite some time and I have the declarative side of MEF down.

Edits:

I'm looking to do something like this:

var myObject = container.Import<MyType>();
4

1 回答 1

0

您可以新建您想要的对象并使用CompositionInitializer来满足您获得的类中的任何 MEF 依赖项。无论如何,这就是我所做的 :) 这是另一篇关于使用 WPF的简短文章,但我认为在 silverlight 中的使用是相同或非常相似的。

于 2013-06-07T16:14:57.870 回答