【发布时间】:2011-03-27 20:09:32
【问题描述】:
我真的不明白它的工作。
假设我有一些具有相同接口的类要导出。
[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service1))]
public class Service1 : IService
{...}
[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service2))]
public class Service2 : IService
{...}
[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service3))]
public class Service3 : IService
{...}
现在我有一个类可以导入 IService,而这个类与它的服务无关。
public class Blup
{
[ImPortingConstructor]
public Blup(IService service)
{}
}
我现在尝试实现的是构建一个 ExportProvider,它在 Compose 上选择正确的导出。
类似这样的:
public TypeExportProvider<TTypeToExport>() : ExportProvider
{}
我真的不知道是怎么回事
protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
应该看起来像。也许有人知道一个博客来阅读这个。有很多自定义 ExportProvider 示例,但不适用于这种情况。
谢谢
【问题讨论】: