Exemple #1
0
        /// <summary>
        /// Parse a query string and insert the found parameters
        /// into the collection of this class.
        /// </summary>
        public void FromUrl(
            string url)
        {
            if (url != null)
            {
                InternalQS.Clear();

                // store the part before, too.
                int qPos = url.IndexOf("?");
                if (qPos >= 0)
                {
                    BeforeUrl = url.Substring(0, qPos - 0);
                    url       = url.Substring(qPos + 1);
                }
                else
                {
                    BeforeUrl = url;
                }

                if (url.Length > 0 && url.Substring(0, 1) == "?")
                {
                    url = url.Substring(1);
                }

                // break the values.
                string[] pairs = url.Split('&');
                foreach (string pair in pairs)
                {
                    string a = string.Empty;
                    string b = string.Empty;

                    string[] singular = pair.Split('=');

                    int j = 0;
                    foreach (string one in singular)
                    {
                        if (j == 0)
                        {
                            a = one;
                        }
                        else
                        {
                            b = one;
                        }

                        j++;
                    }

                    // store.
                    SetParameter(a, System.Web.HttpUtility.UrlDecode(b));
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Removes all parameters.
 /// </summary>
 public void RemoveAllParameters()
 {
     InternalQS.Clear();
 }
Exemple #3
0
 /// <summary>
 /// Removes an parameter (if exists) with the given name.
 /// </summary>
 /// <param name="name">The name of the parameter to remove.</param>
 public void RemoveParameter(
     string name)
 {
     InternalQS.Remove(name);
 }