问题描述
目前我的WPF应用程序导入一部分像这样
Currently my WPF application imports a part like this
[Import(typeof(ILedPanel)]
public ILedPanel Panel { get; set; }
但是,这给了马实现ILedPanel类的单一intance。我真正想要做的就是要创造尽可能多的实例的能力我所需要的。请注意,包括的话,只有一个出口的ILedPanel在任何给定时间的软件
But this gives ma a single intance of the class that implements ILedPanel.What I really want to do is have the ability to create as many instancesthat I need. Please note there is only one Export for ILedPanel includedwith the software at any given time.
(如果我使用的导入与列表这给了我一个实例对于每一个类实现ILedPanel)
(If I use an import with List that gives me one instancefor every class implementing ILedPanel)
有什么建议?
推荐答案
没有内置这在MEF支持的今天,但在此之前恢复到服务定位器,你可以在这里找到一些灵感:了解更多信息。
UPDATE: MEF now has experimental support for this. See this blog post for more information.
这篇关于创建进口MEF部件的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!