Merge pull request #2098 from evincarofautumn/fix-gchandle-assert
[mono.git] / mcs / class / System.Web / System.Web / HttpParamsCollection.cs
index 3c9b9ade25eaae9e93d78e129b3d10918fb3995e..2775240315c61624493311e20c0b60065f1cefd3 100644 (file)
@@ -34,62 +34,35 @@ namespace System.Web
 {
        internal class HttpParamsCollection : WebROCollection
        {
-               private NameValueCollection _queryString;
-               private NameValueCollection _form;
-               private NameValueCollection _serverVariables;
-               private HttpCookieCollection _cookies;
-               private bool _merged;
+               NameValueCollection _queryString;
+               NameValueCollection _form;
+               NameValueCollection _serverVariables;
+               HttpCookieCollection _cookies;
+               bool _merged;
 
                public HttpParamsCollection (NameValueCollection queryString,
-                                                                       NameValueCollection form,
-                                                                       NameValueCollection serverVariables,
-                                                                       HttpCookieCollection cookies)
+                                            NameValueCollection form,
+                                            NameValueCollection serverVariables,
+                                            HttpCookieCollection cookies)
                {
                        _queryString = queryString;
                        _form = form;
                        _serverVariables = serverVariables;
                        _cookies = cookies;
                        _merged = false;
-                       IsReadOnly = true;
+                       Protect ();
                }
 
                public override string Get (string name)
                {
-                       if (_merged)
-                               return base.Get (name);
-
-                       string values = null;
-
-                       string query_value = _queryString [name];
-                       if (query_value != null)
-                               values += query_value;
-
-                       string form_value = _form [name];
-                       if (form_value != null)
-                               values += "," + form_value;
-
-                       string servar_value = _serverVariables [name];
-                       if (servar_value != null)
-                               values += "," + servar_value;
-
-                       HttpCookie answer = _cookies [name];
-                       string cookie_value = ((answer == null) ? null : answer.Value);
-                       if (cookie_value != null)
-                               values += "," + cookie_value;
-
-                       if (values == null)
-                               return null;
-
-                       if (values [0] == ',')
-                               return values.Substring (1);
-
-                       return values;
+                       MergeCollections ();
+                       return base.Get (name);
                }
 
-               private void MergeCollections ()
+               void MergeCollections ()
                {
                        if (_merged)
-                               return;
+                               return;                 
 
                        Unprotect ();
 
@@ -99,9 +72,12 @@ namespace System.Web
 
                        /* special handling for Cookies since
                         * it isn't a NameValueCollection. */
-                       string [] cookies = _cookies.AllKeys;
-                       foreach (string k in cookies)
-                               Add (k, _cookies [k].Value);
+                       for (int i = 0; i < _cookies.Count; i++) {
+                               HttpCookie cookie = _cookies [i];
+                               Add (cookie.Name, cookie.Value);
+                       }
+
+                       _merged = true;
 
                        Protect ();
                }
@@ -118,24 +94,18 @@ namespace System.Web
                        return base.GetKey (index);
                }
 
-               public override string [] GetValues (int index)
-               {
-                       string value = Get (index);
-                       if (value == null)
-                               return null;
-
-                       return value.Split (',');
-               }
-
-               public override string [] GetValues (string name)
-               {
-                       string value = Get (name);
-                       if (value == null)
-                               return null;
-
-                       return value.Split (',');
-               }
-
+               public override string[] GetValues (int index)
+                {
+                       MergeCollections ();
+                       return base.GetValues (index);
+                }
+                
+                public override string[] GetValues (string name)
+                {
+                       MergeCollections ();
+                       return base.GetValues (name);
+                }
+               
                public override void GetObjectData (SerializationInfo info, StreamingContext context)
                {
                        throw new SerializationException ();
@@ -143,8 +113,7 @@ namespace System.Web
 
                public override string [] AllKeys
                {
-                       get
-                       {
+                       get {
                                MergeCollections ();
                                return base.AllKeys;
                        }
@@ -152,8 +121,7 @@ namespace System.Web
 
                public override int Count
                {
-                       get
-                       {
+                       get {
                                MergeCollections ();
                                return base.Count;
                        }