Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set StructureMap 3 Lifecycle

In StructureMap 2 I had something like this:

For<ILogger>().HybridHttpOrThreadLocalScoped().Use<Logger>();

When using Structure Map 3 should I use the following?

For<ILogger>().LifecycleIs<HybridLifecycle>().Use<Logger>();

Then I tried to apply the same change to:

For<IDispatcher>().Transient().Use<Dispatcher>();

And I wasn't able to use:

For<IDispatcher>().LifecycleIs<Transient>().Use<Dispatcher>();

Why?

Thank You, Miguel

like image 704
Miguel Moura Avatar asked Apr 22 '14 21:04

Miguel Moura


1 Answers

First you need to install the new structuremap.web package.

PM> install-package structuremap.web

Then add these namespaces to your class

using StructureMap;
using StructureMap.Web;
using StructureMap.Web.Pipeline;

Now you have access to the HybridHttpOrThreadLocalScoped() as before.

like image 132
VahidN Avatar answered Sep 18 '22 12:09

VahidN