5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006,2010 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 MsmqElementBase
60 ConfigurationPropertyCollection _properties
;
62 protected MsmqElementBase () {
68 [ConfigurationProperty ("customDeadLetterQueue",
69 Options
= ConfigurationPropertyOptions
.None
,
71 public Uri CustomDeadLetterQueue
{
72 get { return (Uri) base ["customDeadLetterQueue"]; }
73 set { base ["customDeadLetterQueue"] = value; }
76 [ConfigurationProperty ("deadLetterQueue",
77 Options
= ConfigurationPropertyOptions
.None
,
78 DefaultValue
= "System")]
79 public DeadLetterQueue DeadLetterQueue
{
80 get { return (DeadLetterQueue) base ["deadLetterQueue"]; }
81 set { base ["deadLetterQueue"] = value; }
84 [ConfigurationProperty ("durable",
85 Options
= ConfigurationPropertyOptions
.None
,
88 get { return (bool) base ["durable"]; }
89 set { base ["durable"] = value; }
92 [ConfigurationProperty ("exactlyOnce",
93 Options
= ConfigurationPropertyOptions
.None
,
95 public bool ExactlyOnce
{
96 get { return (bool) base ["exactlyOnce"]; }
97 set { base ["exactlyOnce"] = value; }
100 [ConfigurationProperty ("maxRetryCycles",
101 Options
= ConfigurationPropertyOptions
.None
,
103 [IntegerValidator (MinValue
= 0,
104 MaxValue
= int.MaxValue
,
105 ExcludeRange
= false)]
106 public int MaxRetryCycles
{
107 get { return (int) base ["maxRetryCycles"]; }
108 set { base ["maxRetryCycles"] = value; }
111 [ConfigurationProperty ("msmqTransportSecurity",
112 Options
= ConfigurationPropertyOptions
.None
)]
113 public MsmqTransportSecurityElement MsmqTransportSecurity
{
114 get { return (MsmqTransportSecurityElement) base ["msmqTransportSecurity"]; }
117 protected override ConfigurationPropertyCollection Properties
{
119 if (_properties
== null) {
120 _properties
= base.Properties
;
121 _properties
.Add (new ConfigurationProperty ("customDeadLetterQueue", typeof (Uri
), null, new UriTypeConverter (), null, ConfigurationPropertyOptions
.None
));
122 _properties
.Add (new ConfigurationProperty ("deadLetterQueue", typeof (DeadLetterQueue
), "System", null, null, ConfigurationPropertyOptions
.None
));
123 _properties
.Add (new ConfigurationProperty ("durable", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
124 _properties
.Add (new ConfigurationProperty ("exactlyOnce", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
125 _properties
.Add (new ConfigurationProperty ("maxRetryCycles", typeof (int), "2", null, new IntegerValidator (0, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
126 _properties
.Add (new ConfigurationProperty ("msmqTransportSecurity", typeof (MsmqTransportSecurityElement
), null, null, null, ConfigurationPropertyOptions
.None
));
127 _properties
.Add (new ConfigurationProperty ("receiveErrorHandling", typeof (ReceiveErrorHandling
), "Fault", null, null, ConfigurationPropertyOptions
.None
));
128 _properties
.Add (new ConfigurationProperty ("receiveRetryCount", typeof (int), "5", null, new IntegerValidator (0, int.MaxValue
, false), ConfigurationPropertyOptions
.None
));
129 _properties
.Add (new ConfigurationProperty ("retryCycleDelay", typeof (TimeSpan
), "00:30:00", null, null, ConfigurationPropertyOptions
.None
));
130 _properties
.Add (new ConfigurationProperty ("timeToLive", typeof (TimeSpan
), "1.00:00:00", null, null, ConfigurationPropertyOptions
.None
));
131 _properties
.Add (new ConfigurationProperty ("useMsmqTracing", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
132 _properties
.Add (new ConfigurationProperty ("useSourceJournal", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
138 [ConfigurationProperty ("receiveErrorHandling",
139 Options
= ConfigurationPropertyOptions
.None
,
140 DefaultValue
= "Fault")]
141 public ReceiveErrorHandling ReceiveErrorHandling
{
142 get { return (ReceiveErrorHandling) base ["receiveErrorHandling"]; }
143 set { base ["receiveErrorHandling"] = value; }
146 [ConfigurationProperty ("receiveRetryCount",
147 Options
= ConfigurationPropertyOptions
.None
,
149 [IntegerValidator (MinValue
= 0,
150 MaxValue
= int.MaxValue
,
151 ExcludeRange
= false)]
152 public int ReceiveRetryCount
{
153 get { return (int) base ["receiveRetryCount"]; }
154 set { base ["receiveRetryCount"] = value; }
157 [ConfigurationProperty ("retryCycleDelay",
158 Options
= ConfigurationPropertyOptions
.None
,
159 DefaultValue
= "00:30:00")]
160 public TimeSpan RetryCycleDelay
{
161 get { return (TimeSpan) base ["retryCycleDelay"]; }
162 set { base ["retryCycleDelay"] = value; }
165 [ConfigurationProperty ("timeToLive",
166 Options
= ConfigurationPropertyOptions
.None
,
167 DefaultValue
= "1.00:00:00")]
168 public TimeSpan TimeToLive
{
169 get { return (TimeSpan) base ["timeToLive"]; }
170 set { base ["timeToLive"] = value; }
173 [ConfigurationProperty ("useMsmqTracing",
174 Options
= ConfigurationPropertyOptions
.None
,
175 DefaultValue
= false)]
176 public bool UseMsmqTracing
{
177 get { return (bool) base ["useMsmqTracing"]; }
178 set { base ["useMsmqTracing"] = value; }
181 [ConfigurationProperty ("useSourceJournal",
182 Options
= ConfigurationPropertyOptions
.None
,
183 DefaultValue
= false)]
184 public bool UseSourceJournal
{
185 get { return (bool) base ["useSourceJournal"]; }
186 set { base ["useSourceJournal"] = value; }
189 public override void ApplyConfiguration (BindingElement bindingElement
)
191 var b
= (System
.ServiceModel
.Channels
.MsmqBindingElementBase
) bindingElement
;
192 base.ApplyConfiguration (b
);
193 b
.CustomDeadLetterQueue
= CustomDeadLetterQueue
;
194 b
.DeadLetterQueue
= DeadLetterQueue
;
196 b
.ExactlyOnce
= ExactlyOnce
;
197 b
.MaxRetryCycles
= MaxRetryCycles
;
198 b
.ReceiveErrorHandling
= ReceiveErrorHandling
;
199 b
.ReceiveRetryCount
= ReceiveRetryCount
;
200 b
.RetryCycleDelay
= RetryCycleDelay
;
201 b
.TimeToLive
= TimeToLive
;
202 b
.UseMsmqTracing
= UseMsmqTracing
;
203 b
.UseSourceJournal
= UseSourceJournal
;
205 var bs
= b
.MsmqTransportSecurity
;
206 var cs
= MsmqTransportSecurity
;
207 bs
.MsmqAuthenticationMode
= cs
.MsmqAuthenticationMode
;
208 bs
.MsmqEncryptionAlgorithm
= cs
.MsmqEncryptionAlgorithm
;
209 bs
.MsmqProtectionLevel
= cs
.MsmqProtectionLevel
;
210 bs
.MsmqSecureHashAlgorithm
= cs
.MsmqSecureHashAlgorithm
;
213 public override void CopyFrom (ServiceModelExtensionElement
from)
215 var e
= (MsmqElementBase
) from;
216 base.CopyFrom (from);
217 CustomDeadLetterQueue
= e
.CustomDeadLetterQueue
;
218 DeadLetterQueue
= e
.DeadLetterQueue
;
220 ExactlyOnce
= e
.ExactlyOnce
;
221 MaxRetryCycles
= e
.MaxRetryCycles
;
222 ReceiveErrorHandling
= e
.ReceiveErrorHandling
;
223 ReceiveRetryCount
= e
.ReceiveRetryCount
;
224 RetryCycleDelay
= e
.RetryCycleDelay
;
225 TimeToLive
= e
.TimeToLive
;
226 UseMsmqTracing
= e
.UseMsmqTracing
;
227 UseSourceJournal
= e
.UseSourceJournal
;
229 var es
= e
.MsmqTransportSecurity
;
230 var cs
= MsmqTransportSecurity
;
231 cs
.MsmqAuthenticationMode
= es
.MsmqAuthenticationMode
;
232 cs
.MsmqEncryptionAlgorithm
= es
.MsmqEncryptionAlgorithm
;
233 cs
.MsmqProtectionLevel
= es
.MsmqProtectionLevel
;
234 cs
.MsmqSecureHashAlgorithm
= es
.MsmqSecureHashAlgorithm
;
237 protected internal override void InitializeFrom (BindingElement bindingElement
)
239 var b
= (System
.ServiceModel
.Channels
.MsmqBindingElementBase
) bindingElement
;
240 base.InitializeFrom (b
);
241 CustomDeadLetterQueue
= b
.CustomDeadLetterQueue
;
242 DeadLetterQueue
= b
.DeadLetterQueue
;
244 ExactlyOnce
= b
.ExactlyOnce
;
245 MaxRetryCycles
= b
.MaxRetryCycles
;
246 ReceiveErrorHandling
= b
.ReceiveErrorHandling
;
247 ReceiveRetryCount
= b
.ReceiveRetryCount
;
248 RetryCycleDelay
= b
.RetryCycleDelay
;
249 TimeToLive
= b
.TimeToLive
;
250 UseMsmqTracing
= b
.UseMsmqTracing
;
251 UseSourceJournal
= b
.UseSourceJournal
;
253 var bs
= b
.MsmqTransportSecurity
;
254 var cs
= MsmqTransportSecurity
;
255 cs
.MsmqAuthenticationMode
= bs
.MsmqAuthenticationMode
;
256 cs
.MsmqEncryptionAlgorithm
= bs
.MsmqEncryptionAlgorithm
;
257 cs
.MsmqProtectionLevel
= bs
.MsmqProtectionLevel
;
258 cs
.MsmqSecureHashAlgorithm
= bs
.MsmqSecureHashAlgorithm
;