PageRenderTime 27ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.ApplicationServer.Http/Microsoft/ApplicationServer/Http/Channels/HttpMessageEncodingReplyChannel.cs

#
C# | 109 lines | 89 code | 17 blank | 3 comment | 3 complexity | 48b6d168362343338d04f3422d360bd0 MD5 | raw file
  1// <copyright>
  2//   Copyright (c) Microsoft Corporation.  All rights reserved.
  3// </copyright>
  4
  5namespace Microsoft.ApplicationServer.Http.Channels
  6{
  7    using System;
  8    using System.ServiceModel;
  9    using System.ServiceModel.Channels;
 10    using Microsoft.ServiceModel.Channels;
 11
 12    internal class HttpMessageEncodingReplyChannel : LayeredChannel<IReplyChannel>, IReplyChannel, IChannel, ICommunicationObject
 13    {
 14        public HttpMessageEncodingReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
 15            : base(channelManager, innerChannel)
 16        {
 17        }
 18
 19        public EndpointAddress LocalAddress
 20        {
 21            get
 22            {
 23                return this.InnerChannel.LocalAddress;
 24            }
 25        }
 26
 27        public IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state)
 28        {
 29            return this.InnerChannel.BeginReceiveRequest(callback, state);
 30        }
 31
 32        public IAsyncResult BeginReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
 33        {
 34            return this.InnerChannel.BeginReceiveRequest(timeout, callback, state);
 35        }
 36
 37        public IAsyncResult BeginTryReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
 38        {
 39            return this.InnerChannel.BeginTryReceiveRequest(timeout, callback, state);
 40        }
 41
 42        public IAsyncResult BeginWaitForRequest(TimeSpan timeout, AsyncCallback callback, object state)
 43        {
 44            return this.InnerChannel.BeginWaitForRequest(timeout, callback, state);
 45        }
 46
 47        public RequestContext EndReceiveRequest(IAsyncResult result)
 48        {
 49            RequestContext innerContext = this.InnerChannel.EndReceiveRequest(result);
 50            return WrapRequestContext(innerContext);
 51        }
 52
 53        public bool EndTryReceiveRequest(IAsyncResult result, out RequestContext context)
 54        {
 55            RequestContext innerContext;
 56            context = null;
 57            if (!this.InnerChannel.EndTryReceiveRequest(result, out innerContext))
 58            {
 59                return false;
 60            }
 61
 62            context = WrapRequestContext(innerContext);
 63            return true;
 64        }
 65
 66        public bool EndWaitForRequest(IAsyncResult result)
 67        {
 68            return this.InnerChannel.EndWaitForRequest(result);
 69        }
 70
 71        public RequestContext ReceiveRequest()
 72        {
 73            RequestContext innerContext = this.InnerChannel.ReceiveRequest();
 74            return WrapRequestContext(innerContext);
 75        }
 76
 77        public RequestContext ReceiveRequest(TimeSpan timeout)
 78        {
 79            RequestContext innerContext = this.InnerChannel.ReceiveRequest(timeout);
 80            return WrapRequestContext(innerContext);
 81        }
 82
 83        public bool TryReceiveRequest(TimeSpan timeout, out RequestContext context)
 84        {
 85            RequestContext innerContext;
 86            if (this.InnerChannel.TryReceiveRequest(timeout, out innerContext))
 87            {
 88                context = WrapRequestContext(innerContext);
 89                return true;
 90            }
 91
 92            context = null;
 93            return false;
 94        }
 95
 96        public bool WaitForRequest(TimeSpan timeout)
 97        {
 98            return this.InnerChannel.WaitForRequest(timeout);
 99        }
100
101        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "disposed later.")]
102        private static RequestContext WrapRequestContext(RequestContext innerContext)
103        {
104            return (innerContext != null) ?
105                new HttpMessageEncodingRequestContext(innerContext) :
106                (RequestContext)null;
107        }
108    }
109}