views:

31

answers:

0

Hi guys,

I would like to know how to make use of SharpArch.WcfClient.Castle.WcfSessionFacility as an alternative to the following verbose-ness.

 public ActionResult Index() {
            IList<TerritoryDto> territories = null;

            // WCF service closing advice taken from http://msdn.microsoft.com/en-us/library/aa355056.aspx
            // As alternative to this verbose-ness, use the SharpArch.WcfClient.Castle.WcfSessionFacility
            // for automatically closing the WCF service.
            try {
                territories = territoriesWcfService.GetTerritories();
                territoriesWcfService.Close();
            }
            catch (CommunicationException) {
                territoriesWcfService.Abort();
            }
            catch (TimeoutException) {
                territoriesWcfService.Abort();
            }
            catch (Exception) {
                territoriesWcfService.Abort();
                throw;
            }

            return View(territories);
        }

The above code has been taken from the TerritoriesController class in SharpArchitecture's NorthWind Sample.

Awaiting Nabeel