PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 9ms 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
 1// <copyright>
 2//   Copyright (c) Microsoft Corporation.  All rights reserved.
 3// </copyright>
 4
 5namespace Microsoft.ServiceModel.Channels
 6{
 7    using System;
 8    using System.ServiceModel;
 9    using System.ServiceModel.Channels;
10    using Microsoft.Server.Common;
11
12    internal abstract class ChannelAcceptor<TChannel> : CommunicationObject, IChannelAcceptor<TChannel>
13        where TChannel : class, IChannel
14    {
15        private ChannelManagerBase channelManager;
16
17        protected ChannelAcceptor(ChannelManagerBase channelManager)
18        {
19            this.channelManager = channelManager;
20        }
21
22        protected ChannelManagerBase ChannelManager
23        {
24            get { return this.channelManager; }
25        }
26
27        protected override TimeSpan DefaultCloseTimeout
28        {
29            get { return ((IDefaultCommunicationTimeouts)this.channelManager).CloseTimeout; }
30        }
31
32        protected override TimeSpan DefaultOpenTimeout
33        {
34            get { return ((IDefaultCommunicationTimeouts)this.channelManager).OpenTimeout; }
35        }
36
37        public abstract TChannel AcceptChannel(TimeSpan timeout);
38
39        public abstract IAsyncResult BeginAcceptChannel(TimeSpan timeout, AsyncCallback callback, object state);
40        
41        public abstract TChannel EndAcceptChannel(IAsyncResult result);
42
43        public abstract bool WaitForChannel(TimeSpan timeout);
44        
45        public abstract IAsyncResult BeginWaitForChannel(TimeSpan timeout, AsyncCallback callback, object state);
46        
47        public abstract bool EndWaitForChannel(IAsyncResult result);
48
49        protected override void OnAbort()
50        {
51        }
52
53        protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
54        {
55            return new CompletedAsyncResult(callback, state);
56        }
57
58        protected override void OnEndClose(IAsyncResult result)
59        {
60            CompletedAsyncResult.End(result);
61        }
62
63        protected override void OnClose(TimeSpan timeout)
64        {
65        }
66
67        protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
68        {
69            return new CompletedAsyncResult(callback, state);
70        }
71
72        protected override void OnEndOpen(IAsyncResult result)
73        {
74            CompletedAsyncResult.End(result);
75        }
76
77        protected override void OnOpen(TimeSpan timeout)
78        {
79        }
80    }
81}