[英]How can I avoid redundant imports in MEF?
Here's the issue... if I use, say a directory catalog in MEF and have some.dll and copy of some.dll, i will get double the exports, even though they are defining the same type, is there a way to resolve this? 这是问题...如果我使用,说MEF中的目录编目并有some.dll和some.dll的副本,我会得到双倍的导出,即使他们定义相同的类型,有没有办法解决这个?
EDIT: the problem isn't with this particular issue, this is just an abstract example of a real issue, for instance, if i have an "extensions" folder, and a way to manually import... it's just something that would be nice to handle. 编辑:问题不在于这个特定的问题,这只是一个真实问题的抽象例子,例如,如果我有一个“扩展”文件夹,以及一种手动导入的方法...它只是一个可能的东西很高兴处理。
You can do this with a FilteredCatalog
(not part of the core MEF distribution.) See the example here: http://mef.codeplex.com/wikipage?title=Filtering%20Catalogs 您可以使用
FilteredCatalog
(不是核心MEF发行版的一部分)来执行此操作。请参阅此处的示例: http : //mef.codeplex.com/wikipage?title = Filtering%20Catalogs
Rather than selecting from the inner catalogs via Where
you may use Distinct
. 而不是从内部目录中选择通过
Where
可以使用Distinct
。 To compare ComposablePartDefinition
s for equality the simplest option is to use ToString
but casting to ReflectionComposablePartDefinition
is also an option. 要比较
ComposablePartDefinition
的相等性,最简单的选择是使用ToString
但也可以选择转换为ReflectionComposablePartDefinition
。
HTH, Nick HTH,尼克
is there a way to resolve this?
有办法解决这个问题吗?
Two options come to mind: 我想到两个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.