PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 0ms 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
Possible License(s): CC-BY-SA-3.0, Apache-2.0
  1. // <copyright>
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. namespace Microsoft.ApplicationServer.Http.Channels
  5. {
  6. using System;
  7. using System.ServiceModel;
  8. using System.ServiceModel.Channels;
  9. using Microsoft.ServiceModel.Channels;
  10. internal class HttpMessageEncodingReplyChannel : LayeredChannel<IReplyChannel>, IReplyChannel, IChannel, ICommunicationObject
  11. {
  12. public HttpMessageEncodingReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
  13. : base(channelManager, innerChannel)
  14. {
  15. }
  16. public EndpointAddress LocalAddress
  17. {
  18. get
  19. {
  20. return this.InnerChannel.LocalAddress;
  21. }
  22. }
  23. public IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state)
  24. {
  25. return this.InnerChannel.BeginReceiveRequest(callback, state);
  26. }
  27. public IAsyncResult BeginReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
  28. {
  29. return this.InnerChannel.BeginReceiveRequest(timeout, callback, state);
  30. }
  31. public IAsyncResult BeginTryReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
  32. {
  33. return this.InnerChannel.BeginTryReceiveRequest(timeout, callback, state);
  34. }
  35. public IAsyncResult BeginWaitForRequest(TimeSpan timeout, AsyncCallback callback, object state)
  36. {
  37. return this.InnerChannel.BeginWaitForRequest(timeout, callback, state);
  38. }
  39. public RequestContext EndReceiveRequest(IAsyncResult result)
  40. {
  41. RequestContext innerContext = this.InnerChannel.EndReceiveRequest(result);
  42. return WrapRequestContext(innerContext);
  43. }
  44. public bool EndTryReceiveRequest(IAsyncResult result, out RequestContext context)
  45. {
  46. RequestContext innerContext;
  47. context = null;
  48. if (!this.InnerChannel.EndTryReceiveRequest(result, out innerContext))
  49. {
  50. return false;
  51. }
  52. context = WrapRequestContext(innerContext);
  53. return true;
  54. }
  55. public bool EndWaitForRequest(IAsyncResult result)
  56. {
  57. return this.InnerChannel.EndWaitForRequest(result);
  58. }
  59. public RequestContext ReceiveRequest()
  60. {
  61. RequestContext innerContext = this.InnerChannel.ReceiveRequest();
  62. return WrapRequestContext(innerContext);
  63. }
  64. public RequestContext ReceiveRequest(TimeSpan timeout)
  65. {
  66. RequestContext innerContext = this.InnerChannel.ReceiveRequest(timeout);
  67. return WrapRequestContext(innerContext);
  68. }
  69. public bool TryReceiveRequest(TimeSpan timeout, out RequestContext context)
  70. {
  71. RequestContext innerContext;
  72. if (this.InnerChannel.TryReceiveRequest(timeout, out innerContext))
  73. {
  74. context = WrapRequestContext(innerContext);
  75. return true;
  76. }
  77. context = null;
  78. return false;
  79. }
  80. public bool WaitForRequest(TimeSpan timeout)
  81. {
  82. return this.InnerChannel.WaitForRequest(timeout);
  83. }
  84. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "disposed later.")]
  85. private static RequestContext WrapRequestContext(RequestContext innerContext)
  86. {
  87. return (innerContext != null) ?
  88. new HttpMessageEncodingRequestContext(innerContext) :
  89. (RequestContext)null;
  90. }
  91. }
  92. }