Click here to Skip to main content
15,886,873 members
Articles / Hosted Services / Azure

RoutingService on Azure

Rate me:
Please Sign up or sign in to vote.
4.89/5 (10 votes)
18 Jul 2011CPOL19 min read 59.9K   429   20  
This article describes a design, implementation and usage of the WCF4 Routing Service hosted by Windows Azure.
//*****************************************************************************
//    Description.....Null Transport 
//                                
//    Author..........Roman Kiss, rkiss@pathcom.com
//    Copyright © 2007 ATZ Consulting Inc.  (see included license.rtf file)     
//                        
//    Date Created:    07/07/07
//
//    Date        Modified By     Description
//-----------------------------------------------------------------------------
//    07/07/07    Roman Kiss     Initial Revision
//    04/04/11    Roman Kiss     Modify for workflow channel
//    07/07/11    Roman Kiss     Modify for azure channel
//*****************************************************************************
//  
#region Namespaces
using System;
using System.ServiceModel.Channels;
#endregion


namespace RKiss.CustomChannels
{
    public class WebRolePublisherTransportBindingElement : TransportBindingElement
    {
        public string RepositorySettingName { get; set; }

        #region Constructors
        public WebRolePublisherTransportBindingElement() : base()
        {
        }
        public WebRolePublisherTransportBindingElement(WebRolePublisherTransportBindingElement elementToBeCloned)
            : base(elementToBeCloned)
        {
            this.RepositorySettingName = elementToBeCloned.RepositorySettingName;
        }
        #endregion

        #region Overrides
        public override string Scheme
        {
            get { return "webrole.pub"; }
        }

        public override BindingElement Clone()
        {
            return new WebRolePublisherTransportBindingElement(this);
        }

        public override T GetProperty<T>(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            return base.GetProperty<T>(context);
        }

        public override bool CanBuildChannelFactory<TChannel>(BindingContext context)
        {

            return typeof(TChannel) == typeof(IOutputChannel) || typeof(TChannel) == typeof(IOutputSessionChannel);
        }

        public override bool CanBuildChannelListener<TChannel>(BindingContext context)
        {
            throw new NotSupportedException("Listener is not supported");
        }

        public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!this.CanBuildChannelFactory<TChannel>(context))
            {
                throw new InvalidOperationException(string.Format("ChannelTypeNotSupported - {0}", typeof(TChannel).Name));
            }
            if (base.ManualAddressing)
            {
                throw new InvalidOperationException("ManualAddressingNotSupported");
            }
            return new WebRolePublisherChannelFactory<TChannel>(this, context);
        }

        public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context)
        {
            throw new NotSupportedException("Listener is not supported");
        }       
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions