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