{
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 ();
/* 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 ();
}
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 ();
public override string [] AllKeys
{
- get
- {
+ get {
MergeCollections ();
return base.AllKeys;
}
public override int Count
{
- get
- {
+ get {
MergeCollections ();
return base.Count;
}