PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.ServiceModel.Internal/Microsoft/ServiceModel/Channels/ChannelAcceptor.cs

#
C# | 81 lines | 59 code | 19 blank | 3 comment | 0 complexity | 8631470b9112191fa95e071af786c053 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.ServiceModel.Channels
  5. {
  6. using System;
  7. using System.ServiceModel;
  8. using System.ServiceModel.Channels;
  9. using Microsoft.Server.Common;
  10. internal abstract class ChannelAcceptor<TChannel> : CommunicationObject, IChannelAcceptor<TChannel>
  11. where TChannel : class, IChannel
  12. {
  13. private ChannelManagerBase channelManager;
  14. protected ChannelAcceptor(ChannelManagerBase channelManager)
  15. {
  16. this.channelManager = channelManager;
  17. }
  18. protected ChannelManagerBase ChannelManager
  19. {
  20. get { return this.channelManager; }
  21. }
  22. protected override TimeSpan DefaultCloseTimeout
  23. {
  24. get { return ((IDefaultCommunicationTimeouts)this.channelManager).CloseTimeout; }
  25. }
  26. protected override TimeSpan DefaultOpenTimeout
  27. {
  28. get { return ((IDefaultCommunicationTimeouts)this.channelManager).OpenTimeout; }
  29. }
  30. public abstract TChannel AcceptChannel(TimeSpan timeout);
  31. public abstract IAsyncResult BeginAcceptChannel(TimeSpan timeout, AsyncCallback callback, object state);
  32. public abstract TChannel EndAcceptChannel(IAsyncResult result);
  33. public abstract bool WaitForChannel(TimeSpan timeout);
  34. public abstract IAsyncResult BeginWaitForChannel(TimeSpan timeout, AsyncCallback callback, object state);
  35. public abstract bool EndWaitForChannel(IAsyncResult result);
  36. protected override void OnAbort()
  37. {
  38. }
  39. protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
  40. {
  41. return new CompletedAsyncResult(callback, state);
  42. }
  43. protected override void OnEndClose(IAsyncResult result)
  44. {
  45. CompletedAsyncResult.End(result);
  46. }
  47. protected override void OnClose(TimeSpan timeout)
  48. {
  49. }
  50. protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
  51. {
  52. return new CompletedAsyncResult(callback, state);
  53. }
  54. protected override void OnEndOpen(IAsyncResult result)
  55. {
  56. CompletedAsyncResult.End(result);
  57. }
  58. protected override void OnOpen(TimeSpan timeout)
  59. {
  60. }
  61. }
  62. }