2010-06-01 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / HttpRuntimeSection.cs
1 //
2 // System.Web.Configuration.HttpRuntimeSection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.ComponentModel;
35 using System.Configuration;
36
37 namespace System.Web.Configuration
38 {
39         public sealed class HttpRuntimeSection : ConfigurationSection
40         {
41                 static ConfigurationProperty apartmentThreadingProp;
42                 static ConfigurationProperty appRequestQueueLimitProp;
43                 static ConfigurationProperty delayNotificationTimeoutProp;
44                 static ConfigurationProperty enableProp;
45                 static ConfigurationProperty enableHeaderCheckingProp;
46                 static ConfigurationProperty enableKernelOutputCacheProp;
47                 static ConfigurationProperty enableVersionHeaderProp;
48                 static ConfigurationProperty executionTimeoutProp;
49                 static ConfigurationProperty maxRequestLengthProp;
50                 static ConfigurationProperty maxWaitChangeNotificationProp;
51                 static ConfigurationProperty minFreeThreadsProp;
52                 static ConfigurationProperty minLocalRequestFreeThreadsProp;
53                 static ConfigurationProperty requestLengthDiskThresholdProp;
54                 static ConfigurationProperty requireRootedSaveAsPathProp;
55                 static ConfigurationProperty sendCacheControlHeaderProp;
56                 static ConfigurationProperty shutdownTimeoutProp;
57                 static ConfigurationProperty useFullyQualifiedRedirectUrlProp;
58                 static ConfigurationProperty waitChangeNotificationProp;
59 #if NET_4_0
60                 static ConfigurationProperty requestPathInvalidCharactersProp;
61                 static ConfigurationProperty requestValidationTypeProp;
62                 static ConfigurationProperty requestValidationModeProp;
63 #endif
64                 static ConfigurationPropertyCollection properties;
65
66                 static HttpRuntimeSection ()
67                 {
68                         apartmentThreadingProp = new ConfigurationProperty ("apartmentThreading", typeof (bool), false);
69                         appRequestQueueLimitProp = new ConfigurationProperty ("appRequestQueueLimit", typeof (int), 5000,
70                                                                               TypeDescriptor.GetConverter (typeof (int)),
71                                                                               new IntegerValidator (1, Int32.MaxValue),
72                                                                               ConfigurationPropertyOptions.None);
73                         delayNotificationTimeoutProp = new ConfigurationProperty ("delayNotificationTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
74                                                                                   PropertyHelper.TimeSpanSecondsConverter,
75                                                                                   PropertyHelper.DefaultValidator,
76                                                                                   ConfigurationPropertyOptions.None);
77                         enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
78                         enableHeaderCheckingProp = new ConfigurationProperty ("enableHeaderChecking", typeof (bool), true);
79                         enableKernelOutputCacheProp = new ConfigurationProperty ("enableKernelOutputCache", typeof (bool), true);
80                         enableVersionHeaderProp = new ConfigurationProperty ("enableVersionHeader", typeof (bool), true);
81                         executionTimeoutProp = new ConfigurationProperty ("executionTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (110),
82                                                                           PropertyHelper.TimeSpanSecondsConverter,
83                                                                           PropertyHelper.PositiveTimeSpanValidator,
84                                                                           ConfigurationPropertyOptions.None);
85                         maxRequestLengthProp = new ConfigurationProperty ("maxRequestLength", typeof (int), 4096,
86                                                                           TypeDescriptor.GetConverter (typeof (int)),
87                                                                           PropertyHelper.IntFromZeroToMaxValidator,
88                                                                           ConfigurationPropertyOptions.None);
89                         maxWaitChangeNotificationProp = new ConfigurationProperty ("maxWaitChangeNotification", typeof (int), 0,
90                                                                                    TypeDescriptor.GetConverter (typeof (int)),
91                                                                                    PropertyHelper.IntFromZeroToMaxValidator,
92                                                                                    ConfigurationPropertyOptions.None);
93                         minFreeThreadsProp = new ConfigurationProperty ("minFreeThreads", typeof (int), 8,
94                                                                         TypeDescriptor.GetConverter (typeof (int)),
95                                                                         PropertyHelper.IntFromZeroToMaxValidator,
96                                                                         ConfigurationPropertyOptions.None);
97                         minLocalRequestFreeThreadsProp = new ConfigurationProperty ("minLocalRequestFreeThreads", typeof (int), 4,
98                                                                                     TypeDescriptor.GetConverter (typeof (int)),
99                                                                                     PropertyHelper.IntFromZeroToMaxValidator,
100                                                                                     ConfigurationPropertyOptions.None);
101                         requestLengthDiskThresholdProp = new ConfigurationProperty ("requestLengthDiskThreshold", typeof (int), 80,
102                                                                                     TypeDescriptor.GetConverter (typeof (int)),
103                                                                                     new IntegerValidator (1, Int32.MaxValue),
104                                                                                     ConfigurationPropertyOptions.None);
105                         requireRootedSaveAsPathProp = new ConfigurationProperty ("requireRootedSaveAsPath", typeof (bool), true);
106                         sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
107                         shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (90),
108                                                                          PropertyHelper.TimeSpanSecondsConverter,
109                                                                          PropertyHelper.DefaultValidator,
110                                                                          ConfigurationPropertyOptions.None);
111                         useFullyQualifiedRedirectUrlProp = new ConfigurationProperty ("useFullyQualifiedRedirectUrl", typeof (bool), false);
112                         waitChangeNotificationProp = new ConfigurationProperty ("waitChangeNotification", typeof (int), 0,
113                                                                                 TypeDescriptor.GetConverter (typeof (int)),
114                                                                                 PropertyHelper.IntFromZeroToMaxValidator,
115                                                                                 ConfigurationPropertyOptions.None);
116 #if NET_4_0
117                         requestPathInvalidCharactersProp = new ConfigurationProperty ("requestPathInvalidCharacters", typeof (string), ",*,%,&,:,\\,?");
118                         requestValidationTypeProp = new ConfigurationProperty ("requestValidationType", typeof (string),"System.Web.Util.RequestValidator",
119                                                                                TypeDescriptor.GetConverter (typeof (string)),
120                                                                                PropertyHelper.NonEmptyStringValidator,
121                                                                                ConfigurationPropertyOptions.None);
122                         requestValidationModeProp = new ConfigurationProperty ("requestValidationMode", typeof (Version), new Version (4, 0),
123                                                                                PropertyHelper.VersionConverter,
124                                                                                PropertyHelper.DefaultValidator,
125                                                                                ConfigurationPropertyOptions.None);
126 #endif
127                         
128                         properties = new ConfigurationPropertyCollection();
129                         properties.Add (apartmentThreadingProp);
130                         properties.Add (appRequestQueueLimitProp);
131                         properties.Add (delayNotificationTimeoutProp);
132                         properties.Add (enableProp);
133                         properties.Add (enableHeaderCheckingProp);
134                         properties.Add (enableKernelOutputCacheProp);
135                         properties.Add (enableVersionHeaderProp);
136                         properties.Add (executionTimeoutProp);
137                         properties.Add (maxRequestLengthProp);
138                         properties.Add (maxWaitChangeNotificationProp);
139                         properties.Add (minFreeThreadsProp);
140                         properties.Add (minLocalRequestFreeThreadsProp);
141                         properties.Add (requestLengthDiskThresholdProp);
142                         properties.Add (requireRootedSaveAsPathProp);
143                         properties.Add (sendCacheControlHeaderProp);
144                         properties.Add (shutdownTimeoutProp);
145                         properties.Add (useFullyQualifiedRedirectUrlProp);
146                         properties.Add (waitChangeNotificationProp);
147 #if NET_4_0
148                         properties.Add (requestPathInvalidCharactersProp);
149                         properties.Add (requestValidationTypeProp);
150                         properties.Add (requestValidationModeProp);
151 #endif
152                 }
153
154                 public HttpRuntimeSection()
155                 {
156                 }
157
158                 [ConfigurationProperty ("apartmentThreading", DefaultValue = "False")]
159                 public bool ApartmentThreading {
160                         get { return (bool) base[apartmentThreadingProp]; }
161                         set { base[apartmentThreadingProp] = value; }
162                 }
163
164                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
165                 [ConfigurationProperty ("appRequestQueueLimit", DefaultValue = "5000")]
166                 public int AppRequestQueueLimit {
167                         get { return (int) base[appRequestQueueLimitProp]; }
168                         set { base[appRequestQueueLimitProp] = value; }
169                 }
170
171                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
172                 [ConfigurationProperty ("delayNotificationTimeout", DefaultValue = "00:00:05")]
173                 public TimeSpan DelayNotificationTimeout {
174                         get { return (TimeSpan) base[delayNotificationTimeoutProp]; }
175                         set { base[delayNotificationTimeoutProp] = value; }
176                 }
177
178                 [ConfigurationProperty ("enable", DefaultValue = "True")]
179                 public bool Enable {
180                         get { return (bool) base[enableProp]; }
181                         set { base[enableProp] = value; }
182                 }
183
184                 [ConfigurationProperty ("enableHeaderChecking", DefaultValue = "True")]
185                 public bool EnableHeaderChecking {
186                         get { return (bool) base[enableHeaderCheckingProp]; }
187                         set { base[enableHeaderCheckingProp] = value; }
188                 }
189
190                 [ConfigurationProperty ("enableKernelOutputCache", DefaultValue = "True")]
191                 public bool EnableKernelOutputCache {
192                         get { return (bool) base[enableKernelOutputCacheProp]; }
193                         set { base[enableKernelOutputCacheProp] = value; }
194                 }
195
196                 [ConfigurationProperty ("enableVersionHeader", DefaultValue = "True")]
197                 public bool EnableVersionHeader {
198                         get { return (bool) base[enableVersionHeaderProp]; }
199                         set { base[enableVersionHeaderProp] = value; }
200                 }
201
202                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
203                 [TimeSpanValidator (MinValueString = "00:00:00")]
204                 [ConfigurationProperty ("executionTimeout", DefaultValue = "00:01:50")]
205                 public TimeSpan ExecutionTimeout {
206                         get { return (TimeSpan) base[executionTimeoutProp]; }
207                         set { base[executionTimeoutProp] = value; }
208                 }
209
210                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
211                 [ConfigurationProperty ("maxRequestLength", DefaultValue = "4096")]
212                 public int MaxRequestLength {
213                         get { return (int) base[maxRequestLengthProp]; }
214                         set { base[maxRequestLengthProp] = value; }
215                 }
216
217                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
218                 [ConfigurationProperty ("maxWaitChangeNotification", DefaultValue = "0")]
219                 public int MaxWaitChangeNotification {
220                         get { return (int) base[maxWaitChangeNotificationProp]; }
221                         set { base[maxWaitChangeNotificationProp] = value; }
222                 }
223
224                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
225                 [ConfigurationProperty ("minFreeThreads", DefaultValue = "8")]
226                 public int MinFreeThreads {
227                         get { return (int) base[minFreeThreadsProp]; }
228                         set { base[minFreeThreadsProp] = value; }
229                 }
230
231                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
232                 [ConfigurationProperty ("minLocalRequestFreeThreads", DefaultValue = "4")]
233                 public int MinLocalRequestFreeThreads {
234                         get { return (int) base[minLocalRequestFreeThreadsProp]; }
235                         set { base[minLocalRequestFreeThreadsProp] = value; }
236                 }
237
238                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
239                 [ConfigurationProperty ("requestLengthDiskThreshold", DefaultValue = "80")]
240                 public int RequestLengthDiskThreshold {
241                         get { return (int) base[requestLengthDiskThresholdProp]; }
242                         set { base[requestLengthDiskThresholdProp] = value; }
243                 }
244
245                 [ConfigurationProperty ("requireRootedSaveAsPath", DefaultValue = "True")]
246                 public bool RequireRootedSaveAsPath {
247                         get { return (bool) base[requireRootedSaveAsPathProp]; }
248                         set { base[requireRootedSaveAsPathProp] = value; }
249                 }
250
251                 [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
252                 public bool SendCacheControlHeader {
253                         get { return (bool) base[sendCacheControlHeaderProp]; }
254                         set { base[sendCacheControlHeaderProp] = value; }
255                 }
256
257                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
258                 [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:01:30")]
259                 public TimeSpan ShutdownTimeout {
260                         get { return (TimeSpan) base[shutdownTimeoutProp]; }
261                         set { base[shutdownTimeoutProp] = value; }
262                 }
263
264                 [ConfigurationProperty ("useFullyQualifiedRedirectUrl", DefaultValue = "False")]
265                 public bool UseFullyQualifiedRedirectUrl {
266                         get { return (bool) base[useFullyQualifiedRedirectUrlProp]; }
267                         set { base[useFullyQualifiedRedirectUrlProp] = value; }
268                 }
269
270                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
271                 [ConfigurationProperty ("waitChangeNotification", DefaultValue = "0")]
272                 public int WaitChangeNotification {
273                         get { return (int) base[waitChangeNotificationProp]; }
274                         set { base[waitChangeNotificationProp] = value; }
275                 }
276
277 #if NET_4_0
278                 [ConfigurationProperty ("requestPathInvalidCharacters", DefaultValue = ",*,%,&,:,\\,?")]
279                 public string RequestPathInvalidCharacters {
280                         get { return (string) base [requestPathInvalidCharactersProp]; }
281                         set { base [requestPathInvalidCharactersProp] = value; }
282                 }
283
284                 [ConfigurationProperty ("requestValidationType", DefaultValue = "System.Web.Util.RequestValidator")]
285                 [StringValidatorAttribute(MinLength = 1)]
286                 public string RequestValidationType {
287                         get { return (string) base [requestValidationTypeProp]; }
288                         set { base [requestValidationTypeProp] = value; }
289                 }
290
291                 [ConfigurationProperty ("requestValidationMode", DefaultValue = "4.0")]
292                 [TypeConverter ("System.Web.Configuration.VersionConverter")]
293                 public Version RequestValidationMode {
294                         get { return (Version) base [requestValidationModeProp]; }
295                         set { base [requestValidationModeProp] = value; }
296                 }
297 #endif
298                 protected override ConfigurationPropertyCollection Properties {
299                         get { return properties; }
300                 }
301         }
302 }
303
304 #endif