Ejemplo n.º 1
0
        /// <summary>
        /// Construct the QueryString object from an existing NameValueCollection
        /// </summary>
        /// <param name="nvc">the NameValueCollection</param>
        /// <param name="encoding">The encoding, or lack of one, that already exists for the passed NameValueCollection</param>
        /// <remarks>If there is a URL set the URL property independently and don't
        /// forget to set IsHTTP too. Encoding should be used to set the pre-existing encoding for the passed querystring.
        /// Note that this is not the encoding to which you want the data converted but the encoding that the data is already in.</remarks>
        public QueryString(NameValueCollection nvc, QueryStringEncoding encoding)
        {
            this.encoding = encoding;

            foreach (string key in nvc.Keys)
            {
                base.Add(key, nvc[key]);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Construct using string having key=value pair format with or without prefixing URL
        /// </summary>
        /// <param name="queryString">the querystring</param>
        /// <param name="encoding">The encoding, or lack of one, that already exists for the passed NameValueCollection</param>
        /// <remarks>Encoding should be used to set the pre-existing encoding for the passed querystring.
        /// Note that this is not the encoding to which you want the data converted but the encoding that the data is already in.</remarks>
        public QueryString(string queryString, QueryStringEncoding encoding)
        {
            this.queryString = queryString.Trim();
            this.IsHTTPS     = false;
            this.url         = QueryString.ParseUrl(this.queryString, ref this.IsHTTPS);

            PopulateCollection();

            this.encoding = encoding;
        }
Ejemplo n.º 3
0
        private void Decode(QueryStringEncoding encoding)
        {
            for (int i = 0; i < this.Keys.Count; i++)
            {
                string newval = null;

                if (encoding == QueryStringEncoding.Html)
                {
                    newval = HttpUtility.HtmlDecode(this[Keys[i]]);
                }
                else
                {
                    newval = HttpUtility.UrlDecode(this[Keys[i]]);
                }

                this[Keys[i]] = newval;
            }
        }