开发者

Adding an instance to a MEF container

开发者 https://www.devze.com 2023-02-15 05:56 出处:网络
How can you add an already created instance to a MEF container/cataloge to use when resolving Im开发者_StackOverflowports. I want the functionality that Unity gives with the RegisterInstance method on

How can you add an already created instance to a MEF container/cataloge to use when resolving Im开发者_StackOverflowports. I want the functionality that Unity gives with the RegisterInstance method on its containers.


You can use the ComposeExportedValue function for this, like so:

var container = new CompositionContainer();
container.ComposeExportedValue<Application>("Application", Application.Current);
0

精彩评论

暂无评论...
验证码 换一张
取 消