문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top