forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpMessageEncodingReplyChannel.cs
More file actions
105 lines (88 loc) · 3.63 KB
/
Copy pathHttpMessageEncodingReplyChannel.cs
File metadata and controls
105 lines (88 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Web.Http.SelfHost.ServiceModel.Channels;
namespace System.Web.Http.SelfHost.Channels
{
internal class HttpMessageEncodingReplyChannel : LayeredChannel<IReplyChannel>, IReplyChannel, IChannel, ICommunicationObject
{
public HttpMessageEncodingReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
: base(channelManager, innerChannel)
{
}
public EndpointAddress LocalAddress
{
get { return InnerChannel.LocalAddress; }
}
public IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state)
{
return InnerChannel.BeginReceiveRequest(callback, state);
}
public IAsyncResult BeginReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
{
return InnerChannel.BeginReceiveRequest(timeout, callback, state);
}
public IAsyncResult BeginTryReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
{
return InnerChannel.BeginTryReceiveRequest(timeout, callback, state);
}
public IAsyncResult BeginWaitForRequest(TimeSpan timeout, AsyncCallback callback, object state)
{
return InnerChannel.BeginWaitForRequest(timeout, callback, state);
}
public RequestContext EndReceiveRequest(IAsyncResult result)
{
RequestContext innerContext = InnerChannel.EndReceiveRequest(result);
return WrapRequestContext(innerContext);
}
public bool EndTryReceiveRequest(IAsyncResult result, out RequestContext context)
{
RequestContext innerContext;
context = null;
if (!InnerChannel.EndTryReceiveRequest(result, out innerContext))
{
return false;
}
context = WrapRequestContext(innerContext);
return true;
}
public bool EndWaitForRequest(IAsyncResult result)
{
return InnerChannel.EndWaitForRequest(result);
}
public RequestContext ReceiveRequest()
{
RequestContext innerContext = InnerChannel.ReceiveRequest();
return WrapRequestContext(innerContext);
}
public RequestContext ReceiveRequest(TimeSpan timeout)
{
RequestContext innerContext = InnerChannel.ReceiveRequest(timeout);
return WrapRequestContext(innerContext);
}
public bool TryReceiveRequest(TimeSpan timeout, out RequestContext context)
{
RequestContext innerContext;
if (InnerChannel.TryReceiveRequest(timeout, out innerContext))
{
context = WrapRequestContext(innerContext);
return true;
}
context = null;
return false;
}
public bool WaitForRequest(TimeSpan timeout)
{
return InnerChannel.WaitForRequest(timeout);
}
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "disposed later.")]
private static RequestContext WrapRequestContext(RequestContext innerContext)
{
return (innerContext != null)
? new HttpMessageEncodingRequestContext(innerContext)
: (RequestContext)null;
}
}
}