2 // ConnectionOrientedTransportElement.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 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.
30 using System
.Collections
;
31 using System
.Collections
.Generic
;
32 using System
.Collections
.ObjectModel
;
33 using System
.ComponentModel
;
34 using System
.Configuration
;
36 using System
.Net
.Security
;
37 using System
.Reflection
;
38 using System
.Security
.Cryptography
.X509Certificates
;
39 using System
.Security
.Principal
;
40 using System
.IdentityModel
.Claims
;
41 using System
.IdentityModel
.Policy
;
42 using System
.IdentityModel
.Tokens
;
43 using System
.ServiceModel
;
44 using System
.ServiceModel
.Channels
;
45 using System
.ServiceModel
.Description
;
46 using System
.ServiceModel
.Diagnostics
;
47 using System
.ServiceModel
.Dispatcher
;
48 using System
.ServiceModel
.MsmqIntegration
;
49 using System
.ServiceModel
.PeerResolvers
;
50 using System
.ServiceModel
.Security
;
51 using System
.Runtime
.Serialization
;
55 namespace System
.ServiceModel
.Configuration
57 public abstract class ConnectionOrientedTransportElement
60 ConfigurationPropertyCollection _properties
;
62 internal ConnectionOrientedTransportElement ()
68 [ConfigurationProperty ("channelInitializationTimeout",
69 Options
= ConfigurationPropertyOptions
.None
,
70 DefaultValue
= "00:00:05")]
71 [TypeConverter (typeof (TimeSpanConverter
))]
72 public TimeSpan ChannelInitializationTimeout
{
73 get { return (TimeSpan) base ["channelInitializationTimeout"]; }
74 set { base ["channelInitializationTimeout"] = value; }
77 [IntegerValidator (MinValue
= 1,
78 MaxValue
= int.MaxValue
,
79 ExcludeRange
= false)]
80 [ConfigurationProperty ("connectionBufferSize",
81 Options
= ConfigurationPropertyOptions
.None
,
82 DefaultValue
= "8192")]
83 public int ConnectionBufferSize
{
84 get { return (int) base ["connectionBufferSize"]; }
85 set { base ["connectionBufferSize"] = value; }
88 [ConfigurationProperty ("hostNameComparisonMode",
89 Options
= ConfigurationPropertyOptions
.None
,
90 DefaultValue
= "StrongWildcard")]
91 public HostNameComparisonMode HostNameComparisonMode
{
92 get { return (HostNameComparisonMode) base ["hostNameComparisonMode"]; }
93 set { base ["hostNameComparisonMode"] = value; }
96 [ConfigurationProperty ("maxBufferSize",
97 Options
= ConfigurationPropertyOptions
.None
,
98 DefaultValue
= "65536")]
99 [IntegerValidator (MinValue
= 1,
100 MaxValue
= int.MaxValue
,
101 ExcludeRange
= false)]
102 public int MaxBufferSize
{
103 get { return (int) base ["maxBufferSize"]; }
104 set { base ["maxBufferSize"] = value; }
107 [ConfigurationProperty ("maxOutputDelay",
108 Options
= ConfigurationPropertyOptions
.None
,
109 DefaultValue
= "00:00:00.2")]
110 [TypeConverter (typeof (TimeSpanConverter
))]
111 public TimeSpan MaxOutputDelay
{
112 get { return (TimeSpan) base ["maxOutputDelay"]; }
113 set { base ["maxOutputDelay"] = value; }
116 [IntegerValidator (MinValue
= 1,
117 MaxValue
= int.MaxValue
,
118 ExcludeRange
= false)]
119 [ConfigurationProperty ("maxPendingAccepts",
120 Options
= ConfigurationPropertyOptions
.None
,
122 public int MaxPendingAccepts
{
123 get { return (int) base ["maxPendingAccepts"]; }
124 set { base ["maxPendingAccepts"] = value; }
127 [ConfigurationProperty ("maxPendingConnections",
128 Options
= ConfigurationPropertyOptions
.None
,
129 DefaultValue
= "10")]
130 [IntegerValidator (MinValue
= 1,
131 MaxValue
= int.MaxValue
,
132 ExcludeRange
= false)]
133 public int MaxPendingConnections
{
134 get { return (int) base ["maxPendingConnections"]; }
135 set { base ["maxPendingConnections"] = value; }
138 protected override ConfigurationPropertyCollection Properties
{
140 if (_properties
== null) {
141 _properties
= base.Properties
;
142 _properties
.Add (new ConfigurationProperty ("channelInitializationTimeout", typeof (TimeSpan
), "00:00:05", null, null, ConfigurationPropertyOptions
.None
));
143 _properties
.Add (new ConfigurationProperty ("connectionBufferSize", typeof (int), "8192", null, new IntegerValidator (1, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
144 _properties
.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode
), "StrongWildcard", null, null, ConfigurationPropertyOptions
.None
));
145 _properties
.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, new IntegerValidator (1, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
146 _properties
.Add (new ConfigurationProperty ("maxOutputDelay", typeof (TimeSpan
), "00:00:00.2", null, null, ConfigurationPropertyOptions
.None
));
147 _properties
.Add (new ConfigurationProperty ("maxPendingAccepts", typeof (int), "1", null, new IntegerValidator (1, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
148 _properties
.Add (new ConfigurationProperty ("maxPendingConnections", typeof (int), "10", null, new IntegerValidator (1, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
149 _properties
.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode
), "Buffered", null, null, ConfigurationPropertyOptions
.None
));
155 [ConfigurationProperty ("transferMode",
156 Options
= ConfigurationPropertyOptions
.None
,
157 DefaultValue
= "Buffered")]
158 public TransferMode TransferMode
{
159 get { return (TransferMode) base ["transferMode"]; }
160 set { base ["transferMode"] = value; }
163 public override void ApplyConfiguration (BindingElement bindingElement
)
165 var e
= (ConnectionOrientedTransportBindingElement
) bindingElement
;
166 e
.ChannelInitializationTimeout
= ChannelInitializationTimeout
;
167 e
.ConnectionBufferSize
= ConnectionBufferSize
;
168 e
.HostNameComparisonMode
= HostNameComparisonMode
;
169 e
.MaxBufferSize
= MaxBufferSize
;
170 e
.MaxOutputDelay
= MaxOutputDelay
;
171 e
.MaxPendingAccepts
= MaxPendingAccepts
;
172 e
.MaxPendingConnections
= MaxPendingConnections
;
173 e
.TransferMode
= TransferMode
;
176 public override void CopyFrom (ServiceModelExtensionElement
from)
178 var e
= (ConnectionOrientedTransportElement
) from;
179 ChannelInitializationTimeout
= e
.ChannelInitializationTimeout
;
180 ConnectionBufferSize
= e
.ConnectionBufferSize
;
181 HostNameComparisonMode
= e
.HostNameComparisonMode
;
182 MaxBufferSize
= e
.MaxBufferSize
;
183 MaxOutputDelay
= e
.MaxOutputDelay
;
184 MaxPendingAccepts
= e
.MaxPendingAccepts
;
185 MaxPendingConnections
= e
.MaxPendingConnections
;
186 TransferMode
= e
.TransferMode
;
189 protected internal override void InitializeFrom (BindingElement bindingElement
)
191 var e
= (ConnectionOrientedTransportBindingElement
) bindingElement
;
192 ChannelInitializationTimeout
= e
.ChannelInitializationTimeout
;
193 ConnectionBufferSize
= e
.ConnectionBufferSize
;
194 HostNameComparisonMode
= e
.HostNameComparisonMode
;
195 MaxBufferSize
= e
.MaxBufferSize
;
196 MaxOutputDelay
= e
.MaxOutputDelay
;
197 MaxPendingAccepts
= e
.MaxPendingAccepts
;
198 MaxPendingConnections
= e
.MaxPendingConnections
;
199 TransferMode
= e
.TransferMode
;