Click here to Skip to main content
15,896,153 members
Articles / Programming Languages / XML

NullTransport for WCF

Rate me:
Please Sign up or sign in to vote.
4.91/5 (48 votes)
1 Oct 200712 min read 189.8K   1.7K   121  
This article describes design, implementation and the usage of the custom in-process transport for Microsoft Windows Communication Foundation (WCF) model.
//*****************************************************************************
//    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
//*****************************************************************************
//  
#region Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Runtime.Serialization;
#endregion

namespace RKiss.NullChannelLib
{
    public class NullInputChannel : NullInputQueueChannelBase<Message>, IInputChannel
    {
        #region Constructors
        internal NullInputChannel(ChannelListenerBase factory, EndpointAddress localAddress)
            : base(factory, localAddress)
        {
        }
        #endregion

        #region Receive
        public IAsyncResult BeginReceive(TimeSpan timeout, AsyncCallback callback, object state)
        {
            return this.BeginDequeue(timeout, callback, state);
        }
        public IAsyncResult BeginReceive(AsyncCallback callback, object state)
        {
            return BeginReceive(base.DefaultReceiveTimeout, callback, state);
        }
        public Message EndReceive(IAsyncResult result)
        {
            return this.EndDequeue(result);
        }
        public Message Receive(TimeSpan timeout)
        {
            return this.Dequeue(timeout);
        }
        public Message Receive()
        {
            return this.Receive(base.DefaultReceiveTimeout);
        }
        #endregion

        #region TryReceive
        public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state)
        {
            return this.BeginDequeue(timeout, callback, state);
        }
        public bool EndTryReceive(IAsyncResult result, out Message message)
        {
            message = null;
            return base.TryDequeue(result, out message);
        }
        public bool TryReceive(TimeSpan timeout, out Message message)
        {
            message = Receive(timeout);
            return true;
        }
        #endregion

        #region WaitForMessage
        public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state)
        {
            throw new NotImplementedException();
        }
        public bool EndWaitForMessage(IAsyncResult result)
        {
            throw new NotImplementedException();
        } 
        public bool WaitForMessage(TimeSpan timeout)
        {
            throw new NotImplementedException();
        }
        #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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


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