GetNameValueLength() static private method

static private GetNameValueLength ( string input, int startIndex, Func nameValueCreator, NameValueHeaderValue &parsedValue ) : int
input string
startIndex int
nameValueCreator Func
parsedValue NameValueHeaderValue
return int
コード例 #1
0
        internal static int GetNameValueListLength(
            string input,
            int startIndex,
            char delimiter,
            ObjectCollection <NameValueHeaderValue> nameValueCollection)
        {
            if (string.IsNullOrEmpty(input) || startIndex >= input.Length)
            {
                return(0);
            }
            int startIndex1 = startIndex + HttpRuleParser.GetWhitespaceLength(input, startIndex);
            int index;

            while (true)
            {
                NameValueHeaderValue parsedValue = (NameValueHeaderValue)null;
                int nameValueLength = NameValueHeaderValue.GetNameValueLength(input, startIndex1, NameValueHeaderValue.s_defaultNameValueCreator, out parsedValue);
                if (nameValueLength != 0)
                {
                    nameValueCollection.Add(parsedValue);
                    int startIndex2 = startIndex1 + nameValueLength;
                    index = startIndex2 + HttpRuleParser.GetWhitespaceLength(input, startIndex2);
                    if (index != input.Length && (int)input[index] == (int)delimiter)
                    {
                        int startIndex3 = index + 1;
                        startIndex1 = startIndex3 + HttpRuleParser.GetWhitespaceLength(input, startIndex3);
                    }
                    else
                    {
                        goto label_6;
                    }
                }
                else
                {
                    break;
                }
            }
            return(0);

label_6:
            return(index - startIndex);
        }
コード例 #2
0
        // Returns the length of a name/value list, separated by 'delimiter'. E.g. "a=b, c=d, e=f" adds 3
        // name/value pairs to 'nameValueCollection' if 'delimiter' equals ','.
        internal static int GetNameValueListLength(string?input, int startIndex, char delimiter,
                                                   ObjectCollection <NameValueHeaderValue> nameValueCollection)
        {
            Debug.Assert(nameValueCollection != null);
            Debug.Assert(startIndex >= 0);

            if ((string.IsNullOrEmpty(input)) || (startIndex >= input.Length))
            {
                return(0);
            }

            int current = startIndex + HttpRuleParser.GetWhitespaceLength(input, startIndex);

            while (true)
            {
                NameValueHeaderValue?parameter;
                int nameValueLength = NameValueHeaderValue.GetNameValueLength(input, current,
                                                                              s_defaultNameValueCreator, out parameter);

                if (nameValueLength == 0)
                {
                    return(0);
                }

                nameValueCollection.Add(parameter !);
                current = current + nameValueLength;
                current = current + HttpRuleParser.GetWhitespaceLength(input, current);

                if ((current == input.Length) || (input[current] != delimiter))
                {
                    // We're done and we have at least one valid name/value pair.
                    return(current - startIndex);
                }

                // input[current] is 'delimiter'. Skip the delimiter and whitespace and try to parse again.
                current++; // skip delimiter.
                current = current + HttpRuleParser.GetWhitespaceLength(input, current);
            }
        }
コード例 #3
0
 internal static int GetNameValueLength(string input, int startIndex, out NameValueHeaderValue parsedValue)
 {
     return(NameValueHeaderValue.GetNameValueLength(input, startIndex, NameValueHeaderValue.defaultNameValueCreator, out parsedValue));
 }