When a Component
is resolved from the Windsor container it must have a definition of the scope it is in. By scope meaning if and how it is reused and when to release the object for the Garbage Collector to destroy. This is the LifeStlye
of the Component
.
The way to specify a LifeStyle is by registering a component. The two most common LifeStyles
are:
Transient
- Each time the component is resolved a new instance of it is produced by the container.
Container.Register(Component.For<Bar>().LifestyleTransient());
Singleton
- Each time the component is resolved the same instance will be returned by the container
Container.Register(Component.For<Foo>().LifestyleSingleton());
Singleton is the default lifestyle, which will be use if you don't specify any explicitly.
Other built-in LifeStyles
include PerWebRequest
,Scoped
, Bound
, PerThread
, Pooled
For more details about the different lifestyles and for what each is good for, refer to Castle's Documentation