Merge pull request #2916 from ludovic-henry/fix-40306
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ProcessModelSection.cs
1 //
2 // System.Web.Configuration.ProcessModelSection
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 using System;
32 using System.ComponentModel;
33 using System.Configuration;
34
35
36 namespace System.Web.Configuration {
37
38         public sealed class ProcessModelSection : ConfigurationSection
39         {
40                 static ConfigurationProperty autoConfigProp;
41                 static ConfigurationProperty clientConnectedCheckProp;
42                 static ConfigurationProperty comAuthenticationLevelProp;
43                 static ConfigurationProperty comImpersonationLevelProp;
44                 static ConfigurationProperty cpuMaskProp;
45                 static ConfigurationProperty enableProp;
46                 static ConfigurationProperty idleTimeoutProp;
47                 static ConfigurationProperty logLevelProp;
48                 static ConfigurationProperty maxAppDomainsProp;
49                 static ConfigurationProperty maxIoThreadsProp;
50                 static ConfigurationProperty maxWorkerThreadsProp;
51                 static ConfigurationProperty memoryLimitProp;
52                 static ConfigurationProperty minIoThreadsProp;
53                 static ConfigurationProperty minWorkerThreadsProp;
54                 static ConfigurationProperty passwordProp;
55                 static ConfigurationProperty pingFrequencyProp;
56                 static ConfigurationProperty pingTimeoutProp;
57                 static ConfigurationProperty requestLimitProp;
58                 static ConfigurationProperty requestQueueLimitProp;
59                 static ConfigurationProperty responseDeadlockIntervalProp;
60                 static ConfigurationProperty responseRestartDeadlockIntervalProp;
61                 static ConfigurationProperty restartQueueLimitProp;
62                 static ConfigurationProperty serverErrorMessageFileProp;
63                 static ConfigurationProperty shutdownTimeoutProp;
64                 static ConfigurationProperty timeoutProp;
65                 static ConfigurationProperty userNameProp;
66                 static ConfigurationProperty webGardenProp;
67                 static ConfigurationPropertyCollection properties;
68
69                 static ConfigurationElementProperty elementProperty;
70
71                 static ProcessModelSection ()
72                 {
73                         autoConfigProp = new ConfigurationProperty ("autoConfig", typeof (bool), false);
74                         clientConnectedCheckProp = new ConfigurationProperty ("clientConnectedCheck", typeof (TimeSpan), TimeSpan.FromSeconds (5),
75                                                                               PropertyHelper.InfiniteTimeSpanConverter,
76                                                                               PropertyHelper.DefaultValidator,
77                                                                               ConfigurationPropertyOptions.None);
78                         comAuthenticationLevelProp = new ConfigurationProperty ("comAuthenticationLevel", typeof (ProcessModelComAuthenticationLevel), ProcessModelComAuthenticationLevel.Connect,
79                                                                                 new GenericEnumConverter (typeof (ProcessModelComAuthenticationLevel)),
80                                                                                 PropertyHelper.DefaultValidator,
81                                                                                 ConfigurationPropertyOptions.None);
82                         comImpersonationLevelProp = new ConfigurationProperty ("comImpersonationLevel", typeof (ProcessModelComImpersonationLevel), ProcessModelComImpersonationLevel.Impersonate,
83                                                                                new GenericEnumConverter (typeof (ProcessModelComImpersonationLevel)),
84                                                                                PropertyHelper.DefaultValidator,
85                                                                                ConfigurationPropertyOptions.None);
86                         cpuMaskProp = new ConfigurationProperty ("cpuMask", typeof (int), (int) (int.MaxValue & 0xfffffff));
87                         enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
88                         idleTimeoutProp = new ConfigurationProperty ("idleTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
89                                                                      PropertyHelper.InfiniteTimeSpanConverter,
90                                                                      PropertyHelper.DefaultValidator,
91                                                                      ConfigurationPropertyOptions.None);
92                         logLevelProp = new ConfigurationProperty ("logLevel", typeof (ProcessModelLogLevel), ProcessModelLogLevel.Errors,
93                                                                   new GenericEnumConverter (typeof (ProcessModelLogLevel)),
94                                                                   PropertyHelper.DefaultValidator,
95                                                                   ConfigurationPropertyOptions.None);
96                         maxAppDomainsProp = new ConfigurationProperty ("maxAppDomains", typeof (int), 2000,
97                                                                        TypeDescriptor.GetConverter (typeof (int)),
98                                                                        PropertyHelper.IntFromOneToMax_1Validator,
99                                                                        ConfigurationPropertyOptions.None);
100                         maxIoThreadsProp = new ConfigurationProperty ("maxIoThreads", typeof (int), 20,
101                                                                        TypeDescriptor.GetConverter (typeof (int)),
102                                                                        PropertyHelper.IntFromOneToMax_1Validator,
103                                                                        ConfigurationPropertyOptions.None);
104                         maxWorkerThreadsProp = new ConfigurationProperty ("maxWorkerThreads", typeof (int), 20,
105                                                                           TypeDescriptor.GetConverter (typeof (int)),
106                                                                           PropertyHelper.IntFromOneToMax_1Validator,
107                                                                           ConfigurationPropertyOptions.None);
108                         memoryLimitProp = new ConfigurationProperty ("memoryLimit", typeof (int), 60);
109                         minIoThreadsProp = new ConfigurationProperty ("minIoThreads", typeof (int), 1,
110                                                                       TypeDescriptor.GetConverter (typeof (int)),
111                                                                       PropertyHelper.IntFromOneToMax_1Validator,
112                                                                       ConfigurationPropertyOptions.None);
113                         minWorkerThreadsProp = new ConfigurationProperty ("minWorkerThreads", typeof (int), 1,
114                                                                           TypeDescriptor.GetConverter (typeof (int)),
115                                                                           PropertyHelper.IntFromOneToMax_1Validator,
116                                                                           ConfigurationPropertyOptions.None);
117                         passwordProp = new ConfigurationProperty ("password", typeof (string), "AutoGenerate");
118                         pingFrequencyProp = new ConfigurationProperty ("pingFrequency", typeof (TimeSpan), TimeSpan.MaxValue,
119                                                                        PropertyHelper.InfiniteTimeSpanConverter,
120                                                                        PropertyHelper.DefaultValidator,
121                                                                        ConfigurationPropertyOptions.None);
122                         pingTimeoutProp = new ConfigurationProperty ("pingTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
123                                                                      PropertyHelper.InfiniteTimeSpanConverter,
124                                                                      PropertyHelper.DefaultValidator,
125                                                                      ConfigurationPropertyOptions.None);
126                         requestLimitProp = new ConfigurationProperty ("requestLimit", typeof (int), Int32.MaxValue,
127                                                                       PropertyHelper.InfiniteIntConverter,
128                                                                       PropertyHelper.IntFromZeroToMaxValidator,
129                                                                       ConfigurationPropertyOptions.None);
130                         requestQueueLimitProp = new ConfigurationProperty ("requestQueueLimit", typeof (int), 5000,
131                                                                       PropertyHelper.InfiniteIntConverter,
132                                                                       PropertyHelper.IntFromZeroToMaxValidator,
133                                                                       ConfigurationPropertyOptions.None);
134                         responseDeadlockIntervalProp = new ConfigurationProperty ("responseDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
135                                                                                   PropertyHelper.InfiniteTimeSpanConverter,
136                                                                                   PropertyHelper.PositiveTimeSpanValidator,
137                                                                                   ConfigurationPropertyOptions.None);
138                         responseRestartDeadlockIntervalProp = new ConfigurationProperty ("responseRestartDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
139                                                                                          PropertyHelper.InfiniteTimeSpanConverter,
140                                                                                          PropertyHelper.DefaultValidator,
141                                                                                          ConfigurationPropertyOptions.None);
142                         restartQueueLimitProp = new ConfigurationProperty ("restartQueueLimit", typeof (int), 10,
143                                                                            PropertyHelper.InfiniteIntConverter,
144                                                                            PropertyHelper.IntFromZeroToMaxValidator,
145                                                                            ConfigurationPropertyOptions.None);
146                         serverErrorMessageFileProp = new ConfigurationProperty ("serverErrorMessageFile", typeof (string), "");
147                         shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
148                                                                          PropertyHelper.InfiniteTimeSpanConverter,
149                                                                          PropertyHelper.PositiveTimeSpanValidator,
150                                                                          ConfigurationPropertyOptions.None);
151                         timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.MaxValue,
152                                                                  PropertyHelper.InfiniteTimeSpanConverter,
153                                                                  PropertyHelper.DefaultValidator,
154                                                                  ConfigurationPropertyOptions.None);
155                         userNameProp = new ConfigurationProperty ("userName", typeof (string), "machine");
156                         webGardenProp = new ConfigurationProperty ("webGarden", typeof (bool), false);
157                         properties = new ConfigurationPropertyCollection ();
158
159                         properties.Add (autoConfigProp);
160                         properties.Add (clientConnectedCheckProp);
161                         properties.Add (comAuthenticationLevelProp);
162                         properties.Add (comImpersonationLevelProp);
163                         properties.Add (cpuMaskProp);
164                         properties.Add (enableProp);
165                         properties.Add (idleTimeoutProp);
166                         properties.Add (logLevelProp);
167                         properties.Add (maxAppDomainsProp);
168                         properties.Add (maxIoThreadsProp);
169                         properties.Add (maxWorkerThreadsProp);
170                         properties.Add (memoryLimitProp);
171                         properties.Add (minIoThreadsProp);
172                         properties.Add (minWorkerThreadsProp);
173                         properties.Add (passwordProp);
174                         properties.Add (pingFrequencyProp);
175                         properties.Add (pingTimeoutProp);
176                         properties.Add (requestLimitProp);
177                         properties.Add (requestQueueLimitProp);
178                         properties.Add (responseDeadlockIntervalProp);
179                         properties.Add (responseRestartDeadlockIntervalProp);
180                         properties.Add (restartQueueLimitProp);
181                         properties.Add (serverErrorMessageFileProp);
182                         properties.Add (shutdownTimeoutProp);
183                         properties.Add (timeoutProp);
184                         properties.Add (userNameProp);
185                         properties.Add (webGardenProp);
186
187                         elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (ProcessModelSection), ValidateElement));
188                 }
189
190                 static void ValidateElement (object o)
191                 {
192                         /* XXX do some sort of element validation here? */
193                 }
194
195                 protected internal override ConfigurationElementProperty ElementProperty {
196                         get { return elementProperty; }
197                 }
198
199                 [ConfigurationProperty ("autoConfig", DefaultValue = "False")]
200                 public bool AutoConfig {
201                         get { return (bool) base [autoConfigProp];}
202                         set { base[autoConfigProp] = value; }
203                 }
204
205                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
206                 [ConfigurationProperty ("clientConnectedCheck", DefaultValue = "00:00:05")]
207                 public TimeSpan ClientConnectedCheck {
208                         get { return (TimeSpan) base [clientConnectedCheckProp];}
209                         set { base[clientConnectedCheckProp] = value; }
210                 }
211
212                 [ConfigurationProperty ("comAuthenticationLevel", DefaultValue = "Connect")]
213                 public ProcessModelComAuthenticationLevel ComAuthenticationLevel {
214                         get { return (ProcessModelComAuthenticationLevel) base [comAuthenticationLevelProp];}
215                         set { base[comAuthenticationLevelProp] = value; }
216                 }
217
218                 [ConfigurationProperty ("comImpersonationLevel", DefaultValue = "Impersonate")]
219                 public ProcessModelComImpersonationLevel ComImpersonationLevel {
220                         get { return (ProcessModelComImpersonationLevel) base [comImpersonationLevelProp];}
221                         set { base[comImpersonationLevelProp] = value; }
222                 }
223
224                 [ConfigurationProperty ("cpuMask", DefaultValue = "0xffffffff")]
225                 public int CpuMask {
226                         get { return (int) base [cpuMaskProp];}
227                         set { base[cpuMaskProp] = value; }
228                 }
229
230                 [ConfigurationProperty ("enable", DefaultValue = "True")]
231                 public bool Enable {
232                         get { return (bool) base [enableProp];}
233                         set { base[enableProp] = value; }
234                 }
235
236                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
237                 [ConfigurationProperty ("idleTimeout", DefaultValue = "10675199.02:48:05.4775807")]
238                 public TimeSpan IdleTimeout {
239                         get { return (TimeSpan) base [idleTimeoutProp];}
240                         set { base[idleTimeoutProp] = value; }
241                 }
242
243                 [ConfigurationProperty ("logLevel", DefaultValue = "Errors")]
244                 public ProcessModelLogLevel LogLevel {
245                         get { return (ProcessModelLogLevel) base [logLevelProp];}
246                         set { base[logLevelProp] = value; }
247                 }
248
249                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
250                 [ConfigurationProperty ("maxAppDomains", DefaultValue = "2000")]
251                 public int MaxAppDomains {
252                         get { return (int) base [maxAppDomainsProp];}
253                         set { base[maxAppDomainsProp] = value; }
254                 }
255
256                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
257                 [ConfigurationProperty ("maxIoThreads", DefaultValue = "20")]
258                 public int MaxIOThreads {
259                         get { return (int) base [maxIoThreadsProp];}
260                         set { base[maxIoThreadsProp] = value; }
261                 }
262
263                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
264                 [ConfigurationProperty ("maxWorkerThreads", DefaultValue = "20")]
265                 public int MaxWorkerThreads {
266                         get { return (int) base [maxWorkerThreadsProp];}
267                         set { base[maxWorkerThreadsProp] = value; }
268                 }
269
270                 [ConfigurationProperty ("memoryLimit", DefaultValue = "60")]
271                 public int MemoryLimit {
272                         get { return (int) base [memoryLimitProp];}
273                         set { base[memoryLimitProp] = value; }
274                 }
275
276                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
277                 [ConfigurationProperty ("minIoThreads", DefaultValue = "1")]
278                 public int MinIOThreads {
279                         get { return (int) base [minIoThreadsProp];}
280                         set { base[minIoThreadsProp] = value; }
281                 }
282
283                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue- 1)]
284                 [ConfigurationProperty ("minWorkerThreads", DefaultValue = "1")]
285                 public int MinWorkerThreads {
286                         get { return (int) base [minWorkerThreadsProp];}
287                         set { base[minWorkerThreadsProp] = value; }
288                 }
289
290                 [ConfigurationProperty ("password", DefaultValue = "AutoGenerate")]
291                 public string Password {
292                         get { return (string) base [passwordProp];}
293                         set { base[passwordProp] = value; }
294                 }
295
296                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
297                 [ConfigurationProperty ("pingFrequency", DefaultValue = "10675199.02:48:05.4775807")]
298                 public TimeSpan PingFrequency {
299                         get { return (TimeSpan) base [pingFrequencyProp];}
300                         set { base[pingFrequencyProp] = value; }
301                 }
302
303                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
304                 [ConfigurationProperty ("pingTimeout", DefaultValue = "10675199.02:48:05.4775807")]
305                 public TimeSpan PingTimeout {
306                         get { return (TimeSpan) base [pingTimeoutProp];}
307                         set { base[pingTimeoutProp] = value; }
308                 }
309
310                 [TypeConverter (typeof (InfiniteIntConverter))]
311                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
312                 [ConfigurationProperty ("requestLimit", DefaultValue = "2147483647")]
313                 public int RequestLimit {
314                         get { return (int) base [requestLimitProp];}
315                         set { base[requestLimitProp] = value; }
316                 }
317
318                 [TypeConverter (typeof (InfiniteIntConverter))]
319                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
320                 [ConfigurationProperty ("requestQueueLimit", DefaultValue = "5000")]
321                 public int RequestQueueLimit {
322                         get { return (int) base [requestQueueLimitProp];}
323                         set { base[requestQueueLimitProp] = value; }
324                 }
325
326                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
327                 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
328                 [ConfigurationProperty ("responseDeadlockInterval", DefaultValue = "00:03:00")]
329                 public TimeSpan ResponseDeadlockInterval {
330                         get { return (TimeSpan) base [responseDeadlockIntervalProp];}
331                         set { base[responseDeadlockIntervalProp] = value; }
332                 }
333
334                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
335                 [ConfigurationProperty ("responseRestartDeadlockInterval", DefaultValue = "00:03:00")]
336                 public TimeSpan ResponseRestartDeadlockInterval {
337                         get { return (TimeSpan) base [responseRestartDeadlockIntervalProp];}
338                         set { base[responseRestartDeadlockIntervalProp] = value; }
339                 }
340
341                 [TypeConverter (typeof (InfiniteIntConverter))]
342                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
343                 [ConfigurationProperty ("restartQueueLimit", DefaultValue = "10")]
344                 public int RestartQueueLimit {
345                         get { return (int) base [restartQueueLimitProp];}
346                         set { base[restartQueueLimitProp] = value; }
347                 }
348
349                 [ConfigurationProperty ("serverErrorMessageFile", DefaultValue = "")]
350                 public string ServerErrorMessageFile {
351                         get { return (string) base [serverErrorMessageFileProp];}
352                         set { base[serverErrorMessageFileProp] = value; }
353                 }
354
355                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
356                 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
357                 [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:00:05")]
358                 public TimeSpan ShutdownTimeout {
359                         get { return (TimeSpan) base [shutdownTimeoutProp];}
360                         set { base[shutdownTimeoutProp] = value; }
361                 }
362
363                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
364                 [ConfigurationProperty ("timeout", DefaultValue = "10675199.02:48:05.4775807")]
365                 public TimeSpan Timeout {
366                         get { return (TimeSpan) base [timeoutProp];}
367                         set { base[timeoutProp] = value; }
368                 }
369
370                 [ConfigurationProperty ("userName", DefaultValue = "machine")]
371                 public string UserName {
372                         get { return (string) base [userNameProp];}
373                         set { base[userNameProp] = value; }
374                 }
375
376                 [ConfigurationProperty ("webGarden", DefaultValue = "False")]
377                 public bool WebGarden {
378                         get { return (bool) base [webGardenProp];}
379                         set { base[webGardenProp] = value; }
380                 }
381
382                 protected internal override ConfigurationPropertyCollection Properties {
383                         get { return properties; }
384                 }
385
386         }
387
388 }
389
390