Can StructureMap be configured so that one can use different .config settings based on whether the p
Posted
by Mark Rogers
on Stack Overflow
See other posts from Stack Overflow
or by Mark Rogers
Published on 2010-05-31T17:50:26Z
Indexed on
2010/05/31
17:53 UTC
Read the original article
Hit count: 220
I know that in StructureMap I can read from my *.config files (or files referenced by them), when I want to pass specific arguments to an object's constructor.
ForRequestedType<IConfiguration>()
.TheDefault.Is.OfConcreteType<SqlServerConfiguration>()
.WithCtorArg("db_server_address")
.EqualToAppSetting("data.db_server_address")
But what I would like to do is read from one config setting in debug mode and another in release mode.
Sure I could surround the .EqualToAppSetting("data.db_server_address")
, with #if DEBUG
, but for some reason those statements make me cringe a little when I put them in. I'd like to know if there was some way to do this with the StructureMap library itself.
So can I feed my objects different settings based on whether the project is built in debug or release mode?
© Stack Overflow or respective owner