* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / System.Web / HttpModuleCollection.cs
index d30cda7066766d7a22dc0439267960ca30a19913..2c3bb7087117dd53338b22f87485ef832e2ca1aa 100644 (file)
@@ -1,10 +1,12 @@
-// \r
-// System.Web.HttpModuleCollection\r
-//\r
-// Author:\r
-//   Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
-//\r
+//
+// System.Web.HttpModuleCollection.cs
+//
+// Author:
+//     Chris Toshok (toshok@novell.com)
+//
 
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-using System;\r
-using System.Collections.Specialized;\r
-\r
-namespace System.Web {\r
-   public sealed class HttpModuleCollection : NameObjectCollectionBase {\r
-      private IHttpModule [] _Modules;\r
-      private string [] _Keys;\r
-\r
-      internal HttpModuleCollection() : base() {\r
-      }\r
-\r
-      internal void AddModule(string key, IHttpModule m) {\r
-         _Modules = null;\r
-         _Keys = null;\r
-\r
-         BaseAdd(key, m);\r
-      }\r
-\r
-      public void CopyTo(Array dest, int index) {\r
-         if (null == _Modules) {\r
-            _Modules = new IHttpModule[Count];\r
-\r
-            for (int i = 0; i != Count; i++) {\r
-               _Modules[i] = Get(i);\r
-            }\r
-         }\r
-\r
-         if (null != _Modules) {\r
-            _Modules.CopyTo(dest, index);\r
-         }\r
-      }\r
-\r
-      public IHttpModule Get(string key) {\r
-         return (IHttpModule) BaseGet(key);\r
-      }\r
-      \r
-      public IHttpModule Get(int index) {\r
-         return (IHttpModule) BaseGet(index);\r
-      }\r
-\r
-      public string GetKey(int index) {\r
-         return BaseGetKey(index);\r
-      }\r
-      \r
-      public string [] AllKeys {\r
-         get {\r
-            if (null == _Keys) {\r
-               _Keys = BaseGetAllKeys();\r
-            }\r
-\r
-            return _Keys;\r
-         }\r
-      }   \r
-\r
-      public IHttpModule this [string key] {\r
-         get {\r
-            return Get(key);\r
-         }\r
-      }\r
-\r
-      public IHttpModule this [int index] {\r
-         get {\r
-            return Get(index);\r
-         }\r
-      }\r
-   }\r
-}\r
+
+using System.Collections.Specialized;
+using System.Security.Permissions;
+
+namespace System.Web {
+
+       // CAS - no InheritanceDemand here as the class is sealed
+       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       public sealed class HttpModuleCollection : NameObjectCollectionBase
+       {
+               internal HttpModuleCollection ()
+               {
+               }
+
+               internal void AddModule (string key, IHttpModule m)
+               {
+                       BaseAdd (key, m);
+               }
+
+               public void CopyTo (Array dest, int index)
+               {
+                       /* XXX this is kind of gross and inefficient
+                        * since it makes a copy of the superclass's
+                        * list */
+                       object[] values = BaseGetAllValues();
+                       values.CopyTo (dest, index);
+               }
+         
+               public string GetKey (int index)
+               {
+                       return BaseGetKey (index);
+               }
+
+               public IHttpModule Get (int index)
+               {
+                       return (IHttpModule)BaseGet (index);
+               }
+
+               public IHttpModule Get (string key)
+               {
+                       return (IHttpModule)BaseGet (key);
+               }
+
+               public IHttpModule this [string key] {
+                       get {
+                               return Get (key);
+                       }
+               }
+
+               public IHttpModule this [int index] {
+                       get {
+                               return Get (index);
+                       }
+               }
+
+               public string[] AllKeys {
+                       get {
+                               return BaseGetAllKeys();
+                       }
+               }
+       }
+}