首页 > 其他 > 详细

Adding an instance to a MEF container

时间:2015-06-16 01:12:23      阅读:252      评论:0      收藏:0      [点我收藏+]

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.

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

var container = new CompositionContainer();
container..ComposeExportedValue<IConfigFileInvoker>(new ConfigFileInvoker());

container..ComposeExportedValue<IConfigFileInvoker>("export-string",new ConfigFileInvoker());

Adding an instance to a MEF container

原文:http://www.cnblogs.com/zjoch/p/4579603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!