LayeredRequestChannel.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // LayeredRequestChannel.cs
  3. //
  4. // Author: Atsushi Enomoto ([email protected])
  5. //
  6. // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.ServiceModel;
  29. namespace System.ServiceModel.Channels
  30. {
  31. internal abstract class LayeredRequestChannel : LayeredCommunicationObject, IRequestChannel
  32. {
  33. IRequestChannel inner;
  34. public LayeredRequestChannel (IRequestChannel source)
  35. : base (source)
  36. {
  37. inner = source;
  38. }
  39. public abstract ChannelFactoryBase Factory { get; }
  40. public override ChannelManagerBase ChannelManager {
  41. get { return Factory; }
  42. }
  43. // IRequestChannel
  44. public virtual EndpointAddress RemoteAddress {
  45. get { return inner.RemoteAddress; }
  46. }
  47. public IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state)
  48. {
  49. // FIXME: send + receive?
  50. return BeginRequest (message, Factory.DefaultSendTimeout, callback, state);
  51. }
  52. public virtual IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
  53. {
  54. ThrowIfNotOpen ();
  55. return OnBeginRequest (message, timeout, callback, state);
  56. }
  57. protected virtual IAsyncResult OnBeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
  58. {
  59. return inner.BeginRequest (message, timeout, callback, state);
  60. }
  61. public Message EndRequest (IAsyncResult result)
  62. {
  63. return OnEndRequest (result);
  64. }
  65. protected virtual Message OnEndRequest (IAsyncResult result)
  66. {
  67. return inner.EndRequest (result);
  68. }
  69. public Message Request (Message message)
  70. {
  71. // FIXME: send + receive?
  72. return Request (message, Factory.DefaultSendTimeout);
  73. }
  74. public Message Request (Message message, TimeSpan timeout)
  75. {
  76. ThrowIfNotOpen ();
  77. return OnRequest (message, timeout);
  78. }
  79. protected virtual Message OnRequest (Message message, TimeSpan timeout)
  80. {
  81. return inner.Request (message, timeout);
  82. }
  83. public virtual Uri Via {
  84. get { return inner.Via; }
  85. }
  86. // IChannel
  87. public virtual T GetProperty<T> () where T : class
  88. {
  89. return inner.GetProperty<T> ();
  90. }
  91. }
  92. }