您可以在自动注册的城堡组件中添加依赖关系吗?
-
30-09-2019 - |
题
我通常使用structuremap,但是在当前的项目中,我使用的是温莎城堡(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);
有什么办法可以使用自动注册类型做到这一点?
解决方案
你用 ConfigureFor<>
可以使您在颗粒级上进行注册的方法。
不隶属于 StackOverflow