2 // ConnectionOrientedTransportBindingElement.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2005 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
;
31 using System
.ServiceModel
.Channels
;
32 using System
.ServiceModel
.Description
;
34 namespace System
.ServiceModel
.Channels
37 public abstract class ConnectionOrientedTransportBindingElement
38 : TransportBindingElement
40 int connection_buf_size
= 0x2000, max_buf_size
= 0x10000,
41 max_pending_conn
= 10, max_pending_accepts
= 1;
42 HostNameComparisonMode host_cmp_mode
= HostNameComparisonMode
.StrongWildcard
;
43 TimeSpan max_output_delay
= TimeSpan
.FromMilliseconds (200);
44 TimeSpan ch_init_timeout
= TimeSpan
.FromSeconds (5);
45 TransferMode transfer_mode
= TransferMode
.Buffered
;
47 internal ConnectionOrientedTransportBindingElement ()
51 internal ConnectionOrientedTransportBindingElement (
52 ConnectionOrientedTransportBindingElement other
)
55 connection_buf_size
= other
.connection_buf_size
;
56 max_buf_size
= other
.max_buf_size
;
57 max_pending_conn
= other
.max_pending_conn
;
58 max_pending_accepts
= other
.max_pending_accepts
;
59 host_cmp_mode
= other
.host_cmp_mode
;
60 max_output_delay
= other
.max_output_delay
;
61 transfer_mode
= other
.transfer_mode
;
64 public TimeSpan ChannelInitializationTimeout
{
65 get { return ch_init_timeout; }
66 set { ch_init_timeout = value; }
69 public int ConnectionBufferSize
{
70 get { return connection_buf_size; }
71 set { connection_buf_size = value; }
74 public HostNameComparisonMode HostNameComparisonMode
{
75 get { return host_cmp_mode; }
76 set { host_cmp_mode = value; }
79 public int MaxBufferSize
{
80 get { return max_buf_size; }
81 set { max_buf_size = value; }
84 public int MaxPendingConnections
{
85 get { return max_pending_conn; }
86 set { max_pending_conn = value; }
89 public TimeSpan MaxOutputDelay
{
90 get { return max_output_delay; }
91 set { max_output_delay = value; }
94 public int MaxPendingAccepts
{
95 get { return max_pending_accepts; }
96 set { max_pending_accepts = value; }
99 public TransferMode TransferMode
{
100 get { return transfer_mode; }
101 set { transfer_mode = value; }
104 public override bool CanBuildChannelFactory
<TChannel
> (
105 BindingContext context
)
107 switch (TransferMode
) {
108 case TransferMode
.Buffered
:
109 case TransferMode
.StreamedResponse
:
110 return typeof (TChannel
) == typeof (IDuplexSessionChannel
);
111 case TransferMode
.Streamed
:
112 case TransferMode
.StreamedRequest
:
113 return typeof (TChannel
) == typeof (IRequestChannel
);
118 public override bool CanBuildChannelListener
<TChannel
> (
119 BindingContext context
)
121 switch (TransferMode
) {
122 case TransferMode
.Buffered
:
123 case TransferMode
.StreamedRequest
:
124 return typeof (TChannel
) == typeof (IDuplexSessionChannel
);
125 case TransferMode
.Streamed
:
126 case TransferMode
.StreamedResponse
:
127 return typeof (TChannel
) == typeof (IReplyChannel
);
132 public override T GetProperty
<T
> (BindingContext context
)
134 // since this class cannot be derived (internal .ctor
135 // only), we cannot examine what this should do.
136 // So, handle all properties in the derived types.
137 return base.GetProperty
<T
> (context
);