New tests.
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Channels / ConnectionOrientedTransportBindingElement.cs
1 //
2 // ConnectionOrientedTransportBindingElement.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005 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.
27 //
28 using System;
29 using System.Collections.Generic;
30 using System.Net;
31 using System.ServiceModel.Channels;
32 using System.ServiceModel.Description;
33
34 namespace System.ServiceModel.Channels
35 {
36         [MonoTODO]
37         public abstract class ConnectionOrientedTransportBindingElement
38                 : TransportBindingElement
39         {
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;
46
47                 internal ConnectionOrientedTransportBindingElement ()
48                 {
49                 }
50
51                 internal ConnectionOrientedTransportBindingElement (
52                         ConnectionOrientedTransportBindingElement other)
53                         : base (other)
54                 {
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;
62                 }
63
64                 public TimeSpan ChannelInitializationTimeout {
65                         get { return ch_init_timeout; }
66                         set { ch_init_timeout = value; }
67                 }
68
69                 public int ConnectionBufferSize {
70                         get { return connection_buf_size; }
71                         set { connection_buf_size = value; }
72                 }
73
74                 public HostNameComparisonMode HostNameComparisonMode {
75                         get { return host_cmp_mode; }
76                         set { host_cmp_mode = value; }
77                 }
78
79                 public int MaxBufferSize {
80                         get { return max_buf_size; }
81                         set { max_buf_size = value; }
82                 }
83
84                 public int MaxPendingConnections {
85                         get { return max_pending_conn; }
86                         set { max_pending_conn = value; }
87                 }
88
89                 public TimeSpan MaxOutputDelay {
90                         get { return max_output_delay; }
91                         set { max_output_delay = value; }
92                 }
93
94                 public int MaxPendingAccepts {
95                         get { return max_pending_accepts; }
96                         set { max_pending_accepts = value; }
97                 }
98
99                 public TransferMode TransferMode {
100                         get { return transfer_mode; }
101                         set { transfer_mode = value; }
102                 }
103                 
104                 public override bool CanBuildChannelFactory<TChannel> (
105                         BindingContext context)
106                 {
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);
114                         }
115                         return false;
116                 }
117
118                 public override bool CanBuildChannelListener<TChannel> (
119                         BindingContext context)
120                 {
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);
128                         }
129                         return false;
130                 }
131
132                 public override T GetProperty<T> (BindingContext context)
133                 {
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);
138                 }
139         }
140 }