internal static int GetStringWithQualityLength(string input, int startIndex, out object parsedValue)
{
Debug.Assert(startIndex >= 0);
parsedValue = null;
if (string.IsNullOrEmpty(input) || (startIndex >= input.Length))
{
return 0;
}
// Parse the value string: <value> in '<value>; q=<quality>'
int valueLength = HttpRuleParser.GetTokenLength(input, startIndex);
if (valueLength == 0)
{
return 0;
}
StringWithQualityHeaderValue result = new StringWithQualityHeaderValue();
result._value = input.Substring(startIndex, valueLength);
int current = startIndex + valueLength;
current = current + HttpRuleParser.GetWhitespaceLength(input, current);
if ((current == input.Length) || (input[current] != ';'))
{
parsedValue = result;
return current - startIndex; // we have a valid token, but no quality.
}
current++; // skip ';' separator
current = current + HttpRuleParser.GetWhitespaceLength(input, current);
// If we found a ';' separator, it must be followed by a quality information
if (!TryReadQuality(input, result, ref current))
{
return 0;
}
parsedValue = result;
return current - startIndex;
}