Introduction
When you request single component twice from Windsor container, will you get two different instances? The answer is, it depends you can control that by setting appropriate lifestyle for the component.
Standard lifestyles (as defined by LifestyleType enum)
Out of the box Windsor provides set of lifestyles you can use.
- Singleton - Just a single instance per container will be created when the component is requested first time. All subsequent calls will return the same instance.
Singleton is the default lifestyle, which will be use if you don't specify any explicitly. - Transient - Each time a component is requested a new instance will be created.
- Thread - Instance of a component will be shared in scope of a single thread of execution.
- PerWebRequest - Instance of a component will be shared in scope of a single web request.
- Pooled - A pool of instances will be created, and then one of them will be returned when requested.
- Custom - Allows you to set your own implementation of ILifestyleManager for the component. Used also be some facilities, like WCF Facility which provides two additional lifestyles - per WCF session and per WCF operation.
