添加实例到MEF容器 [英] Adding an instance to a MEF container
本文介绍了添加实例到MEF容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您如何添加一个已经创建的实例到MEF容器/ cataloge解决进口时使用。我想团结给出了它的容器 RegisterInstance
法的功能。
How can you add an already created instance to a MEF container/cataloge to use when resolving Imports. I want the functionality that Unity gives with the RegisterInstance
method on its containers.
推荐答案
您可以使用 ComposeExportedValue 功能对于这一点,像这样:
You can use the ComposeExportedValue function for this, like so:
var container = new CompositionContainer();
container.ComposeExportedValue<Application>("Application", Application.Current);
这篇关于添加实例到MEF容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文