Exemplo n.º 1
0
            internal void FillFromString(string s, bool urlencoded, Encoding encoding)
            {
                int num = (s != null) ? s.Length : 0;

                for (int i = 0; i < num; i++)
                {
                    int startIndex = i;
                    int num4       = -1;
                    while (i < num)
                    {
                        char ch = s[i];
                        if (ch == '=')
                        {
                            if (num4 < 0)
                            {
                                num4 = i;
                            }
                        }
                        else if (ch == '&')
                        {
                            break;
                        }
                        i++;
                    }
                    string str  = null;
                    string str2 = null;
                    if (num4 >= 0)
                    {
                        str  = s.Substring(startIndex, num4 - startIndex);
                        str2 = s.Substring(num4 + 1, (i - num4) - 1);
                    }
                    else
                    {
                        str2 = s.Substring(startIndex, i - startIndex);
                    }
                    if (urlencoded)
                    {
                        base.Add(UrlUtility.UrlDecode(str, encoding), UrlUtility.UrlDecode(str2, encoding));
                    }
                    else
                    {
                        base.Add(str, str2);
                    }
                    if ((i == (num - 1)) && (s[i] == '&'))
                    {
                        base.Add(null, string.Empty);
                    }
                }
            }
            internal void FillFromString(string s, bool urlencoded, Encoding encoding)
            {
                int l = (s != null) ? s.Length : 0;
                int i = 0;

                while (i < l)
                {
                    // find next & while noting first = on the way (and if there are more)

                    int si = i;
                    int ti = -1;

                    while (i < l)
                    {
                        char ch = s[i];

                        if (ch == '=')
                        {
                            if (ti < 0)
                            {
                                ti = i;
                            }
                        }
                        else if (ch == '&')
                        {
                            break;
                        }

                        i++;
                    }

                    // extract the name / value pair

                    string name  = null;
                    string value = null;

                    if (ti >= 0)
                    {
                        name  = s.Substring(si, ti - si);
                        value = s.Substring(ti + 1, i - ti - 1);
                    }
                    else
                    {
                        value = s.Substring(si, i - si);
                    }

                    // add name / value pair to the collection

                    if (urlencoded)
                    {
                        base.Add(
                            UrlUtility.UrlDecode(name, encoding),
                            UrlUtility.UrlDecode(value, encoding));
                    }
                    else
                    {
                        base.Add(name, value);
                    }

                    // trailing '&'

                    if (i == l - 1 && s[i] == '&')
                    {
                        base.Add(null, string.Empty);
                    }

                    i++;
                }
            }
Exemplo n.º 3
0
            internal void FillFromString(string s, bool urlencoded, Encoding encoding)
            {
                string str;
                int    length;

                if (s != null)
                {
                    length = s.Length;
                }
                else
                {
                    length = 0;
                }
                int num = length;

                for (int i = 0; i < num; i++)
                {
                    int num1 = i;
                    int num2 = -1;
                    while (i < num)
                    {
                        char chr = s[i];
                        if (chr != '=')
                        {
                            if (chr == '&')
                            {
                                break;
                            }
                        }
                        else
                        {
                            if (num2 < 0)
                            {
                                num2 = i;
                            }
                        }
                        i++;
                    }
                    string str1 = null;
                    if (num2 < 0)
                    {
                        str = s.Substring(num1, i - num1);
                    }
                    else
                    {
                        str1 = s.Substring(num1, num2 - num1);
                        str  = s.Substring(num2 + 1, i - num2 - 1);
                    }
                    if (!urlencoded)
                    {
                        base.Add(str1, str);
                    }
                    else
                    {
                        base.Add(UrlUtility.UrlDecode(str1, encoding), UrlUtility.UrlDecode(str, encoding));
                    }
                    if (i == num - 1 && s[i] == '&')
                    {
                        base.Add(null, string.Empty);
                    }
                }
            }