New tests.
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Configuration / ReliableSessionElement.cs
1 //
2 // ReliableSessionElement.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.
27 //
28
29 using System;
30 using System.Collections;
31 using System.Collections.Generic;
32 using System.Collections.ObjectModel;
33 using System.ComponentModel;
34 using System.Configuration;
35 using System.Net;
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;
52 using System.Text;
53 using System.Xml;
54
55 namespace System.ServiceModel.Configuration
56 {
57         public sealed class ReliableSessionElement
58                  : BindingElementExtensionElement
59         {
60                 public ReliableSessionElement () {
61                 }
62
63                 // Properties
64
65                 [ConfigurationProperty ("acknowledgementInterval",
66                          Options = ConfigurationPropertyOptions.None,
67                          DefaultValue = "00:00:00.2")]
68                 [TypeConverter (typeof (TimeSpanConverter))]
69                 public TimeSpan AcknowledgementInterval {
70                         get { return (TimeSpan) base ["acknowledgementInterval"]; }
71                         set { base ["acknowledgementInterval"] = value; }
72                 }
73
74                 public override Type BindingElementType {
75                         get { return typeof (ReliableSessionBindingElement); }
76                 }
77
78                 [ConfigurationProperty ("flowControlEnabled",
79                          Options = ConfigurationPropertyOptions.None,
80                         DefaultValue = true)]
81                 public bool FlowControlEnabled {
82                         get { return (bool) base ["flowControlEnabled"]; }
83                         set { base ["flowControlEnabled"] = value; }
84                 }
85
86                 [ConfigurationProperty ("inactivityTimeout",
87                          Options = ConfigurationPropertyOptions.None,
88                          DefaultValue = "00:10:00")]
89                 [TypeConverter (typeof (TimeSpanConverter))]
90                 public TimeSpan InactivityTimeout {
91                         get { return (TimeSpan) base ["inactivityTimeout"]; }
92                         set { base ["inactivityTimeout"] = value; }
93                 }
94
95                 [ConfigurationProperty ("maxPendingChannels",
96                          Options = ConfigurationPropertyOptions.None,
97                          DefaultValue = "4")]
98                 [IntegerValidator (MinValue = 1,
99                          MaxValue = 16384,
100                         ExcludeRange = false)]
101                 public int MaxPendingChannels {
102                         get { return (int) base ["maxPendingChannels"]; }
103                         set { base ["maxPendingChannels"] = value; }
104                 }
105
106                 [IntegerValidator (MinValue = 1,
107                         MaxValue = int.MaxValue,
108                         ExcludeRange = false)]
109                 [ConfigurationProperty ("maxRetryCount",
110                          Options = ConfigurationPropertyOptions.None,
111                          DefaultValue = "8")]
112                 public int MaxRetryCount {
113                         get { return (int) base ["maxRetryCount"]; }
114                         set { base ["maxRetryCount"] = value; }
115                 }
116
117                 [ConfigurationProperty ("maxTransferWindowSize",
118                          Options = ConfigurationPropertyOptions.None,
119                          DefaultValue = "8")]
120                 [IntegerValidator (MinValue = 1,
121                          MaxValue = 4096,
122                         ExcludeRange = false)]
123                 public int MaxTransferWindowSize {
124                         get { return (int) this ["maxTransferWindowSize"]; }
125                         set { this ["maxTransferWindowSize"] = value; }
126                 }
127
128                 [ConfigurationProperty ("ordered",
129                          Options = ConfigurationPropertyOptions.None,
130                         DefaultValue = true)]
131                 public bool Ordered {
132                         get { return (bool) this ["ordered"]; }
133                         set { this ["ordered"] = value; }
134                 }
135
136                 [ConfigurationPropertyAttribute ("reliableMessagingVersion",
137                         DefaultValue = "WSReliableMessagingFebruary2005")]
138                 [TypeConverter (typeof (ReliableMessagingVersionConverter))]
139                 public ReliableMessagingVersion ReliableMessagingVersion {
140                         get { return (ReliableMessagingVersion) this ["reliableMessagingVersion"]; }
141                         set { this ["reliableMessagingVersion"] = value; }
142                 }
143
144                 protected override ConfigurationPropertyCollection Properties {
145                         get { return base.Properties; }
146                 }
147
148                 protected internal override BindingElement CreateBindingElement ()
149                 {
150                         return new ReliableSessionBindingElement ();
151                 }
152
153                 public override void ApplyConfiguration (BindingElement element)
154                 {
155                         var b = (ReliableSessionBindingElement) element;
156                         b.AcknowledgementInterval = AcknowledgementInterval;
157                         b.FlowControlEnabled = FlowControlEnabled;
158                         b.InactivityTimeout = InactivityTimeout;
159                         b.MaxPendingChannels = MaxPendingChannels;
160                         b.MaxRetryCount = MaxRetryCount;
161                         b.MaxTransferWindowSize = MaxTransferWindowSize;
162                         b.Ordered = Ordered;
163                         b.ReliableMessagingVersion = ReliableMessagingVersion;
164                 }
165
166                 public override void CopyFrom (ServiceModelExtensionElement element)
167                 {
168                         var b = (ReliableSessionElement) element;
169                         AcknowledgementInterval = b.AcknowledgementInterval;
170                         FlowControlEnabled = b.FlowControlEnabled;
171                         InactivityTimeout = b.InactivityTimeout;
172                         MaxPendingChannels = b.MaxPendingChannels;
173                         MaxRetryCount = b.MaxRetryCount;
174                         MaxTransferWindowSize = b.MaxTransferWindowSize;
175                         Ordered = b.Ordered;
176                         ReliableMessagingVersion = b.ReliableMessagingVersion;
177                 }
178
179                 protected internal override void InitializeFrom (BindingElement element)
180                 {
181                         var b = (ReliableSessionBindingElement) element;
182                         AcknowledgementInterval = b.AcknowledgementInterval;
183                         FlowControlEnabled = b.FlowControlEnabled;
184                         InactivityTimeout = b.InactivityTimeout;
185                         MaxPendingChannels = b.MaxPendingChannels;
186                         MaxRetryCount = b.MaxRetryCount;
187                         MaxTransferWindowSize = b.MaxTransferWindowSize;
188                         Ordered = b.Ordered;
189                         ReliableMessagingVersion = b.ReliableMessagingVersion;
190                 }
191
192         }
193
194 }