RequestChannelBinder.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Dispatcher
  5. {
  6. using System;
  7. using System.Runtime;
  8. using System.ServiceModel;
  9. using System.ServiceModel.Channels;
  10. class RequestChannelBinder : IChannelBinder
  11. {
  12. IRequestChannel channel;
  13. internal RequestChannelBinder(IRequestChannel channel)
  14. {
  15. if (channel == null)
  16. {
  17. Fx.Assert("RequestChannelBinder.RequestChannelBinder: (channel != null)");
  18. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
  19. }
  20. this.channel = channel;
  21. }
  22. public IChannel Channel
  23. {
  24. get { return this.channel; }
  25. }
  26. public bool HasSession
  27. {
  28. get { return this.channel is ISessionChannel<IOutputSession>; }
  29. }
  30. public Uri ListenUri
  31. {
  32. get { return null; }
  33. }
  34. public EndpointAddress LocalAddress
  35. {
  36. get { return EndpointAddress.AnonymousAddress; }
  37. }
  38. public EndpointAddress RemoteAddress
  39. {
  40. get { return this.channel.RemoteAddress; }
  41. }
  42. public void Abort()
  43. {
  44. this.channel.Abort();
  45. }
  46. public void CloseAfterFault(TimeSpan timeout)
  47. {
  48. this.channel.Close(timeout);
  49. }
  50. public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state)
  51. {
  52. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  53. }
  54. public bool EndTryReceive(IAsyncResult result, out RequestContext requestContext)
  55. {
  56. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  57. }
  58. public RequestContext CreateRequestContext(Message message)
  59. {
  60. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  61. }
  62. public IAsyncResult BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state)
  63. {
  64. return this.channel.BeginRequest(message, timeout, callback, state);
  65. }
  66. public void EndSend(IAsyncResult result)
  67. {
  68. ValidateNullReply(this.channel.EndRequest(result));
  69. }
  70. public void Send(Message message, TimeSpan timeout)
  71. {
  72. ValidateNullReply(this.channel.Request(message, timeout));
  73. }
  74. public IAsyncResult BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, object state)
  75. {
  76. return this.channel.BeginRequest(message, timeout, callback, state);
  77. }
  78. public Message EndRequest(IAsyncResult result)
  79. {
  80. return this.channel.EndRequest(result);
  81. }
  82. public bool TryReceive(TimeSpan timeout, out RequestContext requestContext)
  83. {
  84. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  85. }
  86. public Message Request(Message message, TimeSpan timeout)
  87. {
  88. return this.channel.Request(message, timeout);
  89. }
  90. void ValidateNullReply(Message message)
  91. {
  92. if (message != null && !(message is NullMessage))
  93. {
  94. ProtocolException error = ProtocolException.OneWayOperationReturnedNonNull(message);
  95. throw System.ServiceModel.Diagnostics.TraceUtility.ThrowHelperError(error, message);
  96. }
  97. }
  98. public bool WaitForMessage(TimeSpan timeout)
  99. {
  100. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  101. }
  102. public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state)
  103. {
  104. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  105. }
  106. public bool EndWaitForMessage(IAsyncResult result)
  107. {
  108. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
  109. }
  110. }
  111. }