我通常使用StructureMap,但在目前的项目中我使用Castle Windsor(2.1)。我找到了一些自动注册类型和接口的代码:
_container.Register(AllTypes.Pick().FromAssembly(GetType().Assembly).WithService.FirstInterface());
但是我想在其中一种类型中添加字符串依赖项。没有像这样的惯例,我可以做到这一点:
var registration = Component.For() .ImplementedBy().DependsOn(new[] { Property.ForKey("someString").Eq("blahblah") });
_container.Register(registration);
我有什么办法可以用自动注册的类型做到这一点吗?
答案 0 :(得分:0)
您使用ConfigureFor<>
方法,可以在粒度级别上微调您的注册。