2 // ServiceRuntimeChannel.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2007 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
30 using System.Reflection;
31 using System.ServiceModel.Channels;
32 using System.ServiceModel.Description;
33 using System.ServiceModel.Dispatcher;
35 namespace System.ServiceModel
37 internal class ServiceRuntimeChannel : CommunicationObject, IContextChannel, IClientChannel
39 IExtensionCollection<IContextChannel> extensions;
40 readonly IChannel channel;
41 bool _allowInitializationUI;
43 readonly TimeSpan _openTimeout;
44 readonly TimeSpan _closeTimeout;
46 public ServiceRuntimeChannel (IChannel channel, TimeSpan openTimeout, TimeSpan closeTimeout)
48 this.channel = channel;
49 this._openTimeout = openTimeout;
50 this._closeTimeout = closeTimeout;
53 #region IContextChannel
56 public bool AllowOutputBatching {
57 get { throw new NotImplementedException (); }
58 set { throw new NotImplementedException (); }
61 public IInputSession InputSession {
63 if (channel is IInputSessionChannel)
64 return ((IInputSessionChannel) channel).Session;
69 public EndpointAddress LocalAddress {
71 if (channel is IReplyChannel)
72 return ((IReplyChannel) channel).LocalAddress;
73 if (channel is IInputChannel)
74 return ((IInputChannel) channel).LocalAddress;
80 public TimeSpan OperationTimeout {
81 get { throw new NotImplementedException (); }
82 set { throw new NotImplementedException (); }
85 public IOutputSession OutputSession {
87 if (channel is IOutputSessionChannel)
88 return ((IOutputSessionChannel) channel).Session;
93 public EndpointAddress RemoteAddress {
95 if (channel is IRequestChannel)
96 return ((IRequestChannel) channel).RemoteAddress;
97 if (channel is IOutputChannel)
98 return ((IOutputChannel) channel).RemoteAddress;
103 public string SessionId {
104 get { return InputSession != null ? InputSession.Id : null; }
109 // CommunicationObject
110 protected internal override TimeSpan DefaultOpenTimeout {
111 get { return _openTimeout; }
114 protected internal override TimeSpan DefaultCloseTimeout {
115 get { return _closeTimeout; }
118 protected override void OnAbort ()
123 protected override IAsyncResult OnBeginClose (
124 TimeSpan timeout, AsyncCallback callback, object state)
126 return channel.BeginClose (timeout, callback, state);
129 protected override void OnEndClose (IAsyncResult result)
131 channel.EndClose (result);
134 protected override void OnClose (TimeSpan timeout)
136 channel.Close (timeout);
139 protected override IAsyncResult OnBeginOpen (
140 TimeSpan timeout, AsyncCallback callback, object state)
142 return channel.BeginOpen (timeout, callback, state);
145 protected override void OnEndOpen (IAsyncResult result)
147 channel.EndOpen (result);
150 protected override void OnOpen (TimeSpan timeout)
152 channel.Open (timeout);
156 public T GetProperty<T> () where T : class
158 return channel.GetProperty<T> ();
161 // IExtensibleObject<IContextChannel>
162 public IExtensionCollection<IContextChannel> Extensions {
164 if (extensions == null)
165 extensions = new ExtensionCollection<IContextChannel> (this);
171 #region IClientChannel Members
173 public bool AllowInitializationUI {
175 return _allowInitializationUI;
178 _allowInitializationUI = value;
182 public bool DidInteractiveInitialization {
183 get { throw new NotImplementedException (); }
190 public IAsyncResult BeginDisplayInitializationUI (AsyncCallback callback, object state) {
191 throw new NotImplementedException ();
194 public void EndDisplayInitializationUI (IAsyncResult result) {
195 throw new NotImplementedException ();
198 public void DisplayInitializationUI () {
199 throw new NotImplementedException ();
202 public event EventHandler<UnknownMessageReceivedEventArgs> UnknownMessageReceived;
206 #region IDisposable Members
208 public void Dispose () {
209 throw new NotImplementedException ();