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的更多相关文章

  1. Microsoft实现的IOC DI之 Unity 、Service Locator、MEF

    这几个工具的站点 Microsoft Unity  http://unity.codeplex.com Service Locator http://commonservicelocator.code ...

  2. Using MEF to Set Up Dependency Injection

    The Managed Extensibility Framework (MEF) is a built-in set of elements that allows you to “export” ...

  3. MEF引起的内存泄露

    也许你编程的时候很小心,注意不引起内存泄露,例如不要被全局Static的变量引用上,注意Singleton的static引用,注意Event Handler注销,注意IDisposable接口实现,而 ...

  4. Laravel之Service Container服务容器

    managing class dependencies and performing dependency injection. Dependency injection is a fancy phr ...

  5. 【总文档】rac增加新节点的方法步骤 How to Add Node/Instance or Remove Node/Instance in 10gR2, 11gR1, 11gR2 and 12c Oracle Clusterware and RAC

    [总文档]How to Add Node/Instance or Remove Node/Instance in 10gR2, 11gR1, 11gR2 and 12c Oracle Clusterw ...

  6. Which dispatch method would be used in Swift?-Existential Container

    In this example: protocol MyProtocol { func testFuncA() } extension MyProtocol { func testFuncA() { ...

  7. java中的重绘

    void java.awt.Container.validate()Validates this container and all of its subcomponents.这个函数更新容器及其全部 ...

  8. Flowplayer-Skin

    SOURCE URL: https://flowplayer.org/docs/skinning.html Skinning with CSS3 Flowplayer skin design is C ...

  9. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

随机推荐

  1. Service(一):认识service、绑定Service

    Activity是与用户打交道的,而Service是在后台运行的. 这个程序介绍了下如何启动和停止一个Service,以及在后台打印消息,我添加了一些注释. 在activity_main中将布局改为线 ...

  2. thinkphp5 IIS7.5 隐藏index.php的方法

    <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.we ...

  3. 插入标识列identity_insert

    插入标识列identity_insert 在进行数据插入时,如果插入列名包括标识列,常常会遇到以下3种提示: 一.“当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'xxxxxxxx ...

  4. 20165333 学习基础和C语言学习基础

    说实话,我并没有什么技能比90%以上的人更好,非要拿一个出来的话,篮球勉强好一点吧.最初接触篮球是小学的时候跟着哥哥看他打球,哥哥的球技在同龄人中算是好的,每次看他各种突破过人,我都觉得特别潇洒帅气, ...

  5. element-ui 2.7.2版本使用 表格展开行 功能遇到的奇葩问题?

    在使用 element-ui 2.7.2版本的时候报下面的错误: [Vue warn]: Error in callback for watcher "data": "E ...

  6. Temp权限导致Win10安装程序失败提示2502/2503错误

    有Win10用户在安装程序时遇到了安装失败错误代码2502/2503的问题.如图: 其原因是Windows Installer安装程序需要当前用户具有C:\Windows\Temp目录的完全控制权限, ...

  7. js 获取时间戳的方法

    (new Date()).valueOf()1541569364658(new Date()).getTime()1541569372623Number(new Date())154156938662 ...

  8. redhat重置密码

    当忘记虚拟机密码时怎么办? 1.启动虚拟机,当虚拟机显示输入enter启动时输入e 2.再次用上下键选中你平时启动linux的那一项(类似于kernel /boot/vmlinuz-2.4.18-14 ...

  9. 【Java】 剑指offer(49) 丑数

    本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 我们把只包含因子2.3和5的数称作丑数(Ugly Number). ...

  10. win7下docker环境搭建nginx+php-fpm+easyswoole+lavarel+mysql开发环境

    win7环境基础在上一篇win7下docker环境搭建nginx+php-fpm+easyswoole开发环境中已经详细叙述搭建完成 本篇文章将叙述如何在上述基础上搭建laravel开发环境,这个其实 ...