X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web%2FHttpCookieCollection.cs;h=e780ff380410b4aa816355d9c2430528f4fe9f02;hb=889b71116d77b38125e67918397b39018f6e14b6;hp=b668291fc71e24c4ebbee6bc7c1ad199599f7464;hpb=bd9f9ee7cb81823608edc76ef9d0b6416783fe71;p=mono.git diff --git a/mcs/class/System.Web/System.Web/HttpCookieCollection.cs b/mcs/class/System.Web/System.Web/HttpCookieCollection.cs index b668291fc71..e780ff38041 100644 --- a/mcs/class/System.Web/System.Web/HttpCookieCollection.cs +++ b/mcs/class/System.Web/System.Web/HttpCookieCollection.cs @@ -6,7 +6,7 @@ // // -// Copyright (C) 2005 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005-2009 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 @@ -28,30 +28,34 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.Collections; using System.Collections.Specialized; - -namespace System.Web { - - public sealed class HttpCookieCollection : NameObjectCollectionBase { - +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 HttpCookieCollection : NameObjectCollectionBase + { private bool auto_fill = false; [Obsolete ("Don't use this constructor, use the (bool, bool) one, as it's more clear what it does")] - internal HttpCookieCollection (HttpResponse Response, bool ReadOnly) + internal HttpCookieCollection (HttpResponse Response, bool ReadOnly) : base (StringComparer.OrdinalIgnoreCase) { auto_fill = Response != null; IsReadOnly = ReadOnly; } - internal HttpCookieCollection (bool auto_fill, bool read_only) + internal HttpCookieCollection (bool auto_fill, bool read_only) : base (StringComparer.OrdinalIgnoreCase) { this.auto_fill = auto_fill; IsReadOnly = read_only; } - internal HttpCookieCollection (string cookies) + internal HttpCookieCollection (string cookies) : base (StringComparer.OrdinalIgnoreCase) { - if (cookies == null || cookies == "") + if (String.IsNullOrEmpty (cookies)) return; string[] cookie_components = cookies.Split (';'); @@ -70,15 +74,12 @@ namespace System.Web { } } - public HttpCookieCollection () + public HttpCookieCollection () : base (StringComparer.OrdinalIgnoreCase) { } public void Add (HttpCookie cookie) { - if (BaseGet (cookie.Name) != null) - return; - BaseAdd (cookie.Name, cookie); } @@ -122,7 +123,7 @@ namespace System.Web { public HttpCookie Get (string name) { - return (HttpCookie)BaseGet (name); + return this [name]; } public HttpCookie this [int index] @@ -146,13 +147,8 @@ namespace System.Web { public string[] AllKeys { get { - /* XXX another inefficient copy due to - * lack of exposure from the base - * class */ string[] keys = new string [Keys.Count]; - for (int i = 0; i < Keys.Count; i ++) - keys[i] = Keys[i]; - + ((ICollection)Keys).CopyTo (keys, 0); return keys; } }