-// \r
-// System.Web.HttpFileCollection\r
-//\r
-// Author:\r
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
-//\r
+//
+// System.Web.HttpFileCollection.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 HttpFileCollection : NameObjectCollectionBase {\r
- private HttpPostedFile [] _AllFiles;\r
- private string [] _AllKeys;\r
-\r
- internal HttpFileCollection() : base() {\r
- }\r
-\r
- internal void AddFile(string name, HttpPostedFile file) {\r
- _AllFiles = null;\r
- _AllKeys = null;\r
-\r
- BaseAdd(name, file);\r
- }\r
-\r
- public void CopyTo(Array Dest, int index) {\r
- if (null == _AllFiles) {\r
- _AllFiles = new HttpPostedFile[Count];\r
- for (int i = 0; i != Count; i++) {\r
- _AllFiles[i] = Get(i);\r
- }\r
- }\r
-\r
- if (null != _AllFiles) {\r
- _AllFiles.CopyTo(Dest, index);\r
- }\r
- }\r
-\r
- public HttpPostedFile Get(string Name) {\r
- return (HttpPostedFile) BaseGet(Name);\r
- }\r
-\r
- public HttpPostedFile Get(int index) {\r
- return (HttpPostedFile) 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 == _AllKeys) {\r
- _AllKeys = BaseGetAllKeys();\r
- }\r
-\r
- return _AllKeys;\r
- }\r
- }\r
- \r
- public HttpPostedFile this [string name] {\r
- get {\r
- return Get(name);\r
- }\r
- }\r
-\r
- public HttpPostedFile this [int index] {\r
- get {\r
- return Get(index);\r
- }\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 HttpFileCollection : NameObjectCollectionBase
+ {
+ internal HttpFileCollection ()
+ {
+ }
+
+ internal void AddFile (string name, HttpPostedFile file)
+ {
+ BaseAdd (name, file);
+ }
+
+ 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 HttpPostedFile Get (int index)
+ {
+ return (HttpPostedFile)BaseGet (index);
+ }
+
+ public HttpPostedFile Get (string key)
+ {
+ return (HttpPostedFile)BaseGet (key);
+ }
+
+ public HttpPostedFile this [string key] {
+ get {
+ return Get (key);
+ }
+ }
+
+ public HttpPostedFile this [int index] {
+ get {
+ return Get (index);
+ }
+ }
+
+ public string[] AllKeys {
+ get {
+ return BaseGetAllKeys();
+ }
+ }
+ }
+}