Dmi*_*kov 2 .net c# dependency-injection castle-windsor ioc-container
我很困惑如何实现满足以下条件的注册:
我使用以下方法,但我不明白把'where'类型的子句放在哪里:
private BasedOnDescriptor CreateDescriptor<TInterface>(Predicate<Type> accepted)
{
return Classes
.FromAssemblyContaining<TInterface>()
.IncludeNonPublicTypes()
.Where(Component.IsInSameNamespaceAs<TInterface>())
.WithService.AllInterfaces()
.WithService.Self();
}
Run Code Online (Sandbox Code Playgroud)
'accepted'子句应该指出应该使用什么类型的名称谢谢.
.If(t => t.Name.EndsWith("Adapter"))
然而,把如何不谈,它可能是类型分成自己的命名空间,用于建筑的清晰度是一个好主意.副作用是,你不需要额外的过滤谓词.