I’m trying to wire up Windsor 3.0 to inject connection strings from my web.config file into my repository classes.
At the moment, I have this syntax:
container.Register(
Component
.For<IFooRepository>().ImplementedBy(SqlFooRepository)
.DependsOn(
Property
.ForKey("sqlConnectionString")
.Eq(ConfigurationManager.ConnectionStrings["foo"].ConnectionString)
)
)
)
Given this must be a fairly common use case, is there some syntactic shorthand in Windsor I can use to bypass the explicit call to ConfigurationManager.ConnectionStrings?
There isn’t. IMHO it’s not worth adding it to Windsor. You can easily write such a shorthand with an extension method: