System.Net.Http.Headers.NameValueHeaderValue.GetValueLength C# (CSharp) Метод

GetValueLength() статический приватный Метод

static private GetValueLength ( string input, int startIndex ) : int
input string
startIndex int
Результат int
        internal static int GetValueLength(string input, int startIndex)
        {
            Debug.Assert(input != null);

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

            int valueLength = HttpRuleParser.GetTokenLength(input, startIndex);

            if (valueLength == 0)
            {
                // A value can either be a token or a quoted string. Check if it is a quoted string.
                if (HttpRuleParser.GetQuotedStringLength(input, startIndex, out valueLength) != HttpParseResult.Parsed)
                {
                    // We have an invalid value. Reset the name and return.
                    return 0;
                }
            }
            return valueLength;
        }

Usage Example

Пример #1
0
 private static void CheckValueFormat(string value)
 {
     if (!string.IsNullOrEmpty(value) && NameValueHeaderValue.GetValueLength(value, 0) != value.Length)
     {
         throw new FormatException(SR.Format((IFormatProvider)CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, (object)value));
     }
 }
All Usage Examples Of System.Net.Http.Headers.NameValueHeaderValue::GetValueLength