2014-08-31 73 views
1

好吧,我想创建一个特定接口的任意实现并解决它们。它实际上类似于插件系统。 “创建您自己intereface X的实施和应用程序没有休息”如何解决统一一个接口的所有实现?

public interface IMenuEntry { ... } 

// auto-mapping (registration-by-convention) 
_container.RegisterTypes(AllClasses.FromAssemblies(assemblies), 
         WithMappings.FromMatchingInterface, 
         // ResolveAll need names for multiple registrations of the same type (?) 
         WithName.TypeName,     
         WithLifetime.ContainerControlled); 

var g = _container.ResolveAll<IMenuEntry>(); // empty - why? 


当我检查我的容器注册我的implemantations在那里,名称为的类的名称 - 不是接口。精彩。 但为什么我不能解决IMenuEntry的所有实现?它总是空的。

回答

3

我正在查看此post,听起来像WithMappings.FromMatchingInterface只会与名为MenuEntryIMenuEntry的类型匹配。

您可以尝试使用WithMappings.FromAllInterfaces

+0

哦......这些都是你浏览文档时的缺点..解决了我的问题。谢谢! – Brettetete 2014-08-31 18:48:01

相关问题