lukiffer
lukiffer

Reputation: 11293

Difference Between Castle Windsor LifeStyle Configurations

What's the difference between these two?

Component.For<IMyType>()
    .LifeStyle
    .PerWebRequest
    .UsingFactoryMethod(() => new MyType());

and

Component.For<IMyType>()
     .UsingFactoryMethod(() => new MyType())
     .LifeStyle
     .Is(LifestyleType.PerWebRequest);

Upvotes: 1

Views: 344

Answers (1)

Daniel Lidstr&#246;m
Daniel Lidstr&#246;m

Reputation: 10260

They are the same. The only difference is that the API has been simplified (made less verbose, more direct). You can simplify it even further with Windsor 3:

Component.For<IMyType>()
    .LifestylePerWebRequest()
    .UsingFactoryMethod(() => new MyType());

Hope this helps!

Upvotes: 3

Related Questions