New tests.
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ProcessModelSection.cs
index 6ed40415369e48747ba14872e1dbcc8a8cb89d07..4e19404eb313e0ada88ba23e06a7a1f7adcf3f28 100644 (file)
@@ -67,33 +67,92 @@ namespace System.Web.Configuration {
                static ConfigurationProperty webGardenProp;
                static ConfigurationPropertyCollection properties;
 
+               static ConfigurationElementProperty elementProperty;
+
                static ProcessModelSection ()
                {
                        autoConfigProp = new ConfigurationProperty ("autoConfig", typeof (bool), false);
-                       clientConnectedCheckProp = new ConfigurationProperty ("clientConnectedCheck", typeof (TimeSpan), TimeSpan.FromSeconds (5));
-                       comAuthenticationLevelProp = new ConfigurationProperty ("comAuthenticationLevel", typeof (ProcessModelComAuthenticationLevel), ProcessModelComAuthenticationLevel.Connect);
-                       comImpersonationLevelProp = new ConfigurationProperty ("comImpersonationLevel", typeof (ProcessModelComImpersonationLevel), ProcessModelComImpersonationLevel.Impersonate);
-                       cpuMaskProp = new ConfigurationProperty ("cpuMask", typeof (int), 0xffffffff);
+                       clientConnectedCheckProp = new ConfigurationProperty ("clientConnectedCheck", typeof (TimeSpan), TimeSpan.FromSeconds (5),
+                                                                             PropertyHelper.InfiniteTimeSpanConverter,
+                                                                             PropertyHelper.DefaultValidator,
+                                                                             ConfigurationPropertyOptions.None);
+                       comAuthenticationLevelProp = new ConfigurationProperty ("comAuthenticationLevel", typeof (ProcessModelComAuthenticationLevel), ProcessModelComAuthenticationLevel.Connect,
+                                                                               new GenericEnumConverter (typeof (ProcessModelComAuthenticationLevel)),
+                                                                               PropertyHelper.DefaultValidator,
+                                                                               ConfigurationPropertyOptions.None);
+                       comImpersonationLevelProp = new ConfigurationProperty ("comImpersonationLevel", typeof (ProcessModelComImpersonationLevel), ProcessModelComImpersonationLevel.Impersonate,
+                                                                              new GenericEnumConverter (typeof (ProcessModelComImpersonationLevel)),
+                                                                              PropertyHelper.DefaultValidator,
+                                                                              ConfigurationPropertyOptions.None);
+                       cpuMaskProp = new ConfigurationProperty ("cpuMask", typeof (int), (int) (int.MaxValue & 0xfffffff));
                        enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
-                       idleTimeoutProp = new ConfigurationProperty ("idleTimeout", typeof (TimeSpan), TimeSpan.MaxValue);
-                       logLevelProp = new ConfigurationProperty ("logLevel", typeof (ProcessModelLogLevel), ProcessModelLogLevel.Errors);
-                       maxAppDomainsProp = new ConfigurationProperty ("maxAppDomains", typeof (int), 2000);
-                       maxIoThreadsProp = new ConfigurationProperty ("maxIoThreads", typeof (int), 20);
-                       maxWorkerThreadsProp = new ConfigurationProperty ("maxWorkerThreads", typeof (int), 20);
+                       idleTimeoutProp = new ConfigurationProperty ("idleTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
+                                                                    PropertyHelper.InfiniteTimeSpanConverter,
+                                                                    PropertyHelper.DefaultValidator,
+                                                                    ConfigurationPropertyOptions.None);
+                       logLevelProp = new ConfigurationProperty ("logLevel", typeof (ProcessModelLogLevel), ProcessModelLogLevel.Errors,
+                                                                 new GenericEnumConverter (typeof (ProcessModelLogLevel)),
+                                                                 PropertyHelper.DefaultValidator,
+                                                                 ConfigurationPropertyOptions.None);
+                       maxAppDomainsProp = new ConfigurationProperty ("maxAppDomains", typeof (int), 2000,
+                                                                      TypeDescriptor.GetConverter (typeof (int)),
+                                                                      PropertyHelper.IntFromOneToMax_1Validator,
+                                                                      ConfigurationPropertyOptions.None);
+                       maxIoThreadsProp = new ConfigurationProperty ("maxIoThreads", typeof (int), 20,
+                                                                      TypeDescriptor.GetConverter (typeof (int)),
+                                                                      PropertyHelper.IntFromOneToMax_1Validator,
+                                                                      ConfigurationPropertyOptions.None);
+                       maxWorkerThreadsProp = new ConfigurationProperty ("maxWorkerThreads", typeof (int), 20,
+                                                                         TypeDescriptor.GetConverter (typeof (int)),
+                                                                         PropertyHelper.IntFromOneToMax_1Validator,
+                                                                         ConfigurationPropertyOptions.None);
                        memoryLimitProp = new ConfigurationProperty ("memoryLimit", typeof (int), 60);
-                       minIoThreadsProp = new ConfigurationProperty ("minIoThreads", typeof (int), 1);
-                       minWorkerThreadsProp = new ConfigurationProperty ("minWorkerThreads", typeof (int), 1);
+                       minIoThreadsProp = new ConfigurationProperty ("minIoThreads", typeof (int), 1,
+                                                                     TypeDescriptor.GetConverter (typeof (int)),
+                                                                     PropertyHelper.IntFromOneToMax_1Validator,
+                                                                     ConfigurationPropertyOptions.None);
+                       minWorkerThreadsProp = new ConfigurationProperty ("minWorkerThreads", typeof (int), 1,
+                                                                         TypeDescriptor.GetConverter (typeof (int)),
+                                                                         PropertyHelper.IntFromOneToMax_1Validator,
+                                                                         ConfigurationPropertyOptions.None);
                        passwordProp = new ConfigurationProperty ("password", typeof (string), "AutoGenerate");
-                       pingFrequencyProp = new ConfigurationProperty ("pingFrequency", typeof (TimeSpan), TimeSpan.MaxValue);
-                       pingTimeoutProp = new ConfigurationProperty ("pingTimeout", typeof (TimeSpan), TimeSpan.MaxValue);
-                       requestLimitProp = new ConfigurationProperty ("requestLimit", typeof (int), Int32.MaxValue);
-                       requestQueueLimitProp = new ConfigurationProperty ("requestQueueLimit", typeof (int), 5000);
-                       responseDeadlockIntervalProp = new ConfigurationProperty ("responseDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3));
-                       responseRestartDeadlockIntervalProp = new ConfigurationProperty ("responseRestartDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3));
-                       restartQueueLimitProp = new ConfigurationProperty ("restartQueueLimit", typeof (int), 10);
+                       pingFrequencyProp = new ConfigurationProperty ("pingFrequency", typeof (TimeSpan), TimeSpan.MaxValue,
+                                                                      PropertyHelper.InfiniteTimeSpanConverter,
+                                                                      PropertyHelper.DefaultValidator,
+                                                                      ConfigurationPropertyOptions.None);
+                       pingTimeoutProp = new ConfigurationProperty ("pingTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
+                                                                    PropertyHelper.InfiniteTimeSpanConverter,
+                                                                    PropertyHelper.DefaultValidator,
+                                                                    ConfigurationPropertyOptions.None);
+                       requestLimitProp = new ConfigurationProperty ("requestLimit", typeof (int), Int32.MaxValue,
+                                                                     PropertyHelper.InfiniteIntConverter,
+                                                                     PropertyHelper.IntFromZeroToMaxValidator,
+                                                                     ConfigurationPropertyOptions.None);
+                       requestQueueLimitProp = new ConfigurationProperty ("requestQueueLimit", typeof (int), 5000,
+                                                                     PropertyHelper.InfiniteIntConverter,
+                                                                     PropertyHelper.IntFromZeroToMaxValidator,
+                                                                     ConfigurationPropertyOptions.None);
+                       responseDeadlockIntervalProp = new ConfigurationProperty ("responseDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
+                                                                                 PropertyHelper.InfiniteTimeSpanConverter,
+                                                                                 PropertyHelper.PositiveTimeSpanValidator,
+                                                                                 ConfigurationPropertyOptions.None);
+                       responseRestartDeadlockIntervalProp = new ConfigurationProperty ("responseRestartDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
+                                                                                        PropertyHelper.InfiniteTimeSpanConverter,
+                                                                                        PropertyHelper.DefaultValidator,
+                                                                                        ConfigurationPropertyOptions.None);
+                       restartQueueLimitProp = new ConfigurationProperty ("restartQueueLimit", typeof (int), 10,
+                                                                          PropertyHelper.InfiniteIntConverter,
+                                                                          PropertyHelper.IntFromZeroToMaxValidator,
+                                                                          ConfigurationPropertyOptions.None);
                        serverErrorMessageFileProp = new ConfigurationProperty ("serverErrorMessageFile", typeof (string), "");
-                       shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5));
-                       timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.MaxValue);
+                       shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
+                                                                        PropertyHelper.InfiniteTimeSpanConverter,
+                                                                        PropertyHelper.PositiveTimeSpanValidator,
+                                                                        ConfigurationPropertyOptions.None);
+                       timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.MaxValue,
+                                                                PropertyHelper.InfiniteTimeSpanConverter,
+                                                                PropertyHelper.DefaultValidator,
+                                                                ConfigurationPropertyOptions.None);
                        userNameProp = new ConfigurationProperty ("userName", typeof (string), "machine");
                        webGardenProp = new ConfigurationProperty ("webGarden", typeof (bool), false);
                        properties = new ConfigurationPropertyCollection ();
@@ -125,6 +184,17 @@ namespace System.Web.Configuration {
                        properties.Add (timeoutProp);
                        properties.Add (userNameProp);
                        properties.Add (webGardenProp);
+
+                       elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (ProcessModelSection), ValidateElement));
+               }
+
+               static void ValidateElement (object o)
+               {
+                       /* XXX do some sort of element validation here? */
+               }
+
+               protected override ConfigurationElementProperty ElementProperty {
+                       get { return elementProperty; }
                }
 
                [ConfigurationProperty ("autoConfig", DefaultValue = "False")]
@@ -310,13 +380,6 @@ namespace System.Web.Configuration {
                        set { base[webGardenProp] = value; }
                }
 
-#if notyet
-               [MonoTODO]
-               public ConfigurationElementProperty ElementProperty {
-                       get { throw new NotImplementedException (); }
-               }
-#endif
-
                protected override ConfigurationPropertyCollection Properties {
                        get { return properties; }
                }