New test.
[mono.git] / mcs / class / System.Web / System.Web.Configuration / ModulesConfiguration.cs
index e4cf54efc67dcb5c1122cbb6200156f9aaf9246a..a99a2ff778e169eebb127f84a09d2ee0e865669f 100644 (file)
@@ -37,7 +37,6 @@ namespace System.Web.Configuration
        class ModuleItem {
                public string Name;
                public Type Type;
-               public IHttpModule Instance;
                
                public ModuleItem (string name, Type type)
                {
@@ -48,7 +47,11 @@ namespace System.Web.Configuration
                
        class ModulesConfiguration
        {
-               public ArrayList Modules;
+               ArrayList Modules;
+
+               private ModulesConfiguration ()
+               {
+               }
 
                public ModulesConfiguration (ModulesConfiguration parent)
                {
@@ -71,7 +74,7 @@ namespace System.Web.Configuration
                                item_type = Type.GetType (type, true);
                        } catch (Exception e){
                                throw new HttpException (
-                                       String.Format ("Failed to load module `{0}' from type `{1}'", name, type));
+                                       String.Format ("Failed to load module `{0}' from type `{1}'", name, type), e);
                        }
 
                        if (!typeof (IHttpModule).IsAssignableFrom (item_type))
@@ -102,18 +105,16 @@ namespace System.Web.Configuration
                        Modules.Clear ();
                }
 
-               public void LoadModules (HttpApplication app)
+               public HttpModuleCollection LoadModules (HttpApplication app)
                {
+                       HttpModuleCollection coll = new HttpModuleCollection ();
                        foreach (ModuleItem item in Modules){
-                               item.Instance = (IHttpModule) Activator.CreateInstance (item.Type, true);
-                               item.Instance.Init (app);
+                               IHttpModule module = (IHttpModule) Activator.CreateInstance (item.Type, true);
+                               module.Init (app);
+                               coll.AddModule (item.Name, module);
                        }
-               }
 
-               public void StopModules ()
-               {
-                       foreach (ModuleItem item in Modules)
-                               item.Instance.Dispose ();
+                       return coll;
                }
        }
 }