* xbuild/Microsoft.Common.targets (_RecordCleanFile): Append list of
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Channels / OneWayBindingElement.cs
blobea747e14680fd36f2c238d3574dbfecaf2b4bf8b
1 //
2 // OneWayBindingElement.cs
3 //
4 // Author:
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
28 using System;
29 using System.Collections.Generic;
30 using System.ServiceModel.Description;
31 using System.ServiceModel.Security;
32 using System.ServiceModel.Channels;
34 namespace System.ServiceModel.Channels
36 public sealed class OneWayBindingElement : BindingElement
38 public OneWayBindingElement ()
40 pool = new ChannelPoolSettings ();
43 OneWayBindingElement (OneWayBindingElement other)
45 pool = new ChannelPoolSettings (other.pool);
48 ChannelPoolSettings pool;
50 public ChannelPoolSettings ChannelPoolSettings {
51 get { return pool; }
54 [MonoTODO ("It generates just pass-thru factory")]
55 public override IChannelFactory<TChannel>
56 BuildChannelFactory<TChannel> (BindingContext context)
58 if (typeof (TChannel) == typeof (IOutputSessionChannel) ||
59 typeof (TChannel) == typeof (IOutputChannel))
60 return new OneWayChannelFactory<TChannel> (context.BuildInnerChannelFactory<TChannel> ());
61 throw new ArgumentException (String.Format ("The requested channel type '{0}' is not supported by this binding element", typeof (TChannel)));
64 [MonoTODO ("It generates just pass-thru listener")]
65 public override IChannelListener<TChannel>
66 BuildChannelListener<TChannel> (
67 BindingContext context)
69 if (typeof (TChannel) == typeof (IInputSessionChannel) ||
70 typeof (TChannel) == typeof (IInputChannel))
71 return new OneWayChannelListener<TChannel> (context.BuildInnerChannelListener<TChannel> ());
72 throw new ArgumentException (String.Format ("The requested channel type '{0}' is not supported by this binding element", typeof (TChannel)));
75 public override bool CanBuildChannelFactory<TChannel> (
76 BindingContext context)
78 return typeof (TChannel) == typeof (IOutputSessionChannel) ||
79 typeof (TChannel) == typeof (IOutputChannel);
82 public override bool CanBuildChannelListener<TChannel> (
83 BindingContext context)
85 return typeof (TChannel) == typeof (IInputSessionChannel) ||
86 typeof (TChannel) == typeof (IInputChannel);
89 public override BindingElement Clone ()
91 return new OneWayBindingElement (this);
94 [MonoTODO]
95 public override T GetProperty<T> (BindingContext context)
97 throw new NotImplementedException ();
101 class OneWayChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
103 IChannelFactory<TChannel> inner;
105 public OneWayChannelFactory (IChannelFactory<TChannel> inner)
107 this.inner = inner;
110 protected override TChannel OnCreateChannel (EndpointAddress address, Uri via)
112 return inner.CreateChannel (address, via);
115 protected override void OnOpen (TimeSpan timeout)
117 inner.Open (timeout);
120 protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
122 return inner.BeginOpen (timeout, callback, state);
125 protected override void OnEndOpen (IAsyncResult result)
127 inner.EndOpen (result);
130 protected override void OnClose (TimeSpan timeout)
132 inner.Close (timeout);
135 protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
137 return inner.BeginClose (timeout, callback, state);
140 protected override void OnEndClose (IAsyncResult result)
142 inner.EndClose (result);
146 class OneWayChannelListener<TChannel> : ChannelListenerBase<TChannel>
147 where TChannel : class, IChannel
149 IChannelListener<TChannel> inner;
151 public OneWayChannelListener (IChannelListener<TChannel> inner)
153 this.inner = inner;
156 public override Uri Uri {
157 get { return inner.Uri; }
160 protected override void OnAbort ()
162 inner.Abort ();
165 protected override void OnOpen (TimeSpan timeout)
167 inner.Open (timeout);
170 protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
172 return inner.BeginOpen (timeout, callback, state);
175 protected override void OnEndOpen (IAsyncResult result)
177 inner.EndOpen (result);
180 protected override void OnClose (TimeSpan timeout)
182 inner.Close (timeout);
185 protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
187 return inner.BeginClose (timeout, callback, state);
190 protected override void OnEndClose (IAsyncResult result)
192 inner.EndClose (result);
195 protected override bool OnWaitForChannel (TimeSpan timeout)
197 return inner.WaitForChannel (timeout);
200 protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
202 return inner.BeginWaitForChannel (timeout, callback, state);
205 protected override bool OnEndWaitForChannel (IAsyncResult result)
207 return inner.EndWaitForChannel (result);
210 protected override TChannel OnAcceptChannel (TimeSpan timeout)
212 return inner.AcceptChannel (timeout);
215 protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout, AsyncCallback callback, object state)
217 return inner.BeginAcceptChannel (timeout, callback, state);
220 protected override TChannel OnEndAcceptChannel (IAsyncResult result)
222 return inner.EndAcceptChannel (result);