Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Structuremap 3.0 EqualToAppSetting

I have upgraded to SM 3.0 and now, amongst other breaking changes I find that EqualToAppSetting is gone.

I used to be able to do

  .Use<SomeType>().Ctor<SomeType>("connectionStr").EqualToAppSetting("myAppSetting");

where of course myAppSetting is pulled from the app.config or the web.config.

Anyone know how to do that now? or some other work around?

like image 332
Raif Avatar asked Oct 01 '22 13:10

Raif


1 Answers

Looks like it was deprecated in version3.

The recommended way to do this is fairly complex I think. http://lostechies.com/joshuaflanagan/2009/07/13/how-we-handle-application-configuration/

A quick workaround would be to just create a variable called settings and is the Is method.

var settings = ConfigurationManager.AppSettings;
x.For<ISearchStatsProvider>().Use<SearchStatsProvider>()
                             .Ctor<string>("solrUrl").Is(settings["SolrUrl"]);
like image 120
Vadim Rybak Avatar answered Oct 04 '22 18:10

Vadim Rybak