예제 #1
0
        private void ParseRequestQueryParameters()
        {
            var splitUrl = this.Url.Split('?');

            if (splitUrl.Length < 2)
            {
                return;
            }

            string query = splitUrl[1];

            // remove fragment from query params
            string queryParams = query.Split('#')[0];

            string[] pairs = queryParams.Split('&');

            foreach (var pair in pairs)
            {
                string[] queryPair = pair.Split('=');
                string   key       = queryPair[0];
                string   value     = queryPair[1];

                CoreValidator.ThrowIfNullOrEmptyInQueryParams(key, nameof(key));
                CoreValidator.ThrowIfNullOrEmptyInQueryParams(value, nameof(value));

                if (!this.QueryData.ContainsKey(key))
                {
                    this.QueryData.Add(key, new List <string>());
                }

                ((IList <string>) this.QueryData[key]).Add(value);

                /*
                 * if(this.QueryData.ContainsKey(key))
                 * {
                 *  this.QueryData[key] = new List<string>() { value };
                 * }
                 * else
                 * {
                 *  this.QueryData.Add(key, value);
                 * }
                 */
            }
        }