如何使用Windsor容器将appSettings条目(从app.config或web.config)的值注入服务?如果我想将一个Windsor属性的值注入服务中,我会做这样的事情:
<properties>
<importantIntegerProperty>666</importantIntegerProperty>
</properties>
<component
id="myComponent"
service="MyApp.IService, MyApp"
type="MyApp.Service, MyApp"
>
<parameters>
<importantInteger>#{importantIntegerProperty}</importantInteger>
</parameters>
</component>
Run Code Online (Sandbox Code Playgroud)
但是,我真正想做的是#{importantIntegerProperty}从应用程序设置变量中获取值,该变量可能是这样定义的:
<appSettings>
<add key="importantInteger" value="666"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
编辑:澄清; 我意识到,温莎和David Hayden的文章指出,滑盖式枪口指的是实际上是关于他自己的(David Hayden的)IoC容器,而不是温莎.
我肯定不是第一个遇到这个问题的人,所以我想知道的是其他人如何解决这个问题?