0

我通常使用 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);

有什么办法可以用自动注册的类型来做到这一点?

4

1 回答 1

0

您使用ConfigureFor<>的方法可以让您在粒度级别上微调您的注册。

于 2010-09-03T13:32:23.250 回答