Question

The following code not working on StructureMap 3:

x.For<Environment>()
    .LifecycleIs(StructureMap.Pipeline.Lifecycles.GetLifecycle(InstanceScope.HttpContext))
    .Use(c => Environment.GetEnvironment("APP"));
x.SelectConstructor(() => new HelpController());

InstanceScope.HttpContext not working StructureMap 3

SelectConstructor() not working on StructureMap 3

Was it helpful?

Solution

The "new" syntax for Lifecycles, which is also available in Structuremap 2, is the following

x.For<Environment>()
    .LifecycleIs<HttpContextLifecycle>()
    .Use(c => Environment.GetEnvironment("APP"));

EDIT:

The replacement for SelectConstructor is now under PolicyExpression

x.Policies.ConstructorSelector(...);

There's a change to the way ConstructorSelector works. Best idea is to have a look at the Test source, to see how it it used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top