Welcome Guest, you are in: Login

Castle Project

RSS RSS

Navigation (Windsor)






Search the wiki
»

PoweredBy

This documentation is a work in progress.

Let us know if some information is not clear, inaccurate or missing. Also feel free to update the wiki yourself.

WCF Facility - Lifestyles

RSS
Modified on 2010/05/20 07:43 by Krzysztof Ko┼║mic Categorized as Facilities, WCF-Facility

Introduction

WCF Facility contains two contextual lifestyles

PerWcfSession lifestyle

If you're using sessionful binding you may want some components to live for the scope of the session. For that you use PerWcfSession lifestyle.

You attach the lifestyles using extension method, so you first need to add the following using statement:
using Castle.Facilities.WcfIntegration;

Then you can register your component with the lifestyle:

container.Register(
   Component.For<IOne>().ImplementedBy<One>().LifeStyle.PerWcfSession());

Now the instance of the component will be shared across the lifetime of the WCF session.

PerWcfOperation lifestyle

If you want to scope component per operation, you use PerWcfOperation lifestyle. It works pretty much like PerWcfSession lifestyle.

container.Register(
   Component.For<IOne>().ImplementedBy<One>().LifeStyle.PerWcfOperation());

Image
Fallback behavior

When the component with either of the above lifestyles is being resolved not within Wcf session or Wcf operation, an exception will be thrown.

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.