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

static private GetProductLength ( string input, int startIndex, ProductHeaderValue &parsedValue ) : int
input string
startIndex int
parsedValue ProductHeaderValue
Результат int
Пример #1
0
        private static int ParseProduct(string value, int startIndex, out object?parsedValue)
        {
            int resultLength = ProductHeaderValue.GetProductLength(value, startIndex, out ProductHeaderValue? temp);

            parsedValue = temp;
            return(resultLength);
        }
Пример #2
0
        internal static int GetProductInfoLength(string?input, int startIndex, out ProductInfoHeaderValue?parsedValue)
        {
            Debug.Assert(startIndex >= 0);

            parsedValue = null;

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

            int current = startIndex;

            // Caller must remove leading whitespace.
            string?            comment = null;
            ProductHeaderValue?product = null;

            if (input[current] == '(')
            {
                int commentLength = 0;
                if (HttpRuleParser.GetCommentLength(input, current, out commentLength) != HttpParseResult.Parsed)
                {
                    return(0);
                }

                comment = input.Substring(current, commentLength);

                current = current + commentLength;
                current = current + HttpRuleParser.GetWhitespaceLength(input, current);

                parsedValue = new ProductInfoHeaderValue(comment);
            }
            else
            {
                // Trailing whitespace is removed by GetProductLength().
                int productLength = ProductHeaderValue.GetProductLength(input, current, out product);

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

                current = current + productLength;

                parsedValue = new ProductInfoHeaderValue(product !);
            }

            return(current - startIndex);
        }
        internal static int GetProductInfoLength(string input, int startIndex, out ProductInfoHeaderValue parsedValue)
        {
            Contract.Requires(startIndex >= 0);

            parsedValue = null;

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

            int current = startIndex;

            // Caller must remove leading whitespaces.
            string             comment = null;
            ProductHeaderValue product = null;

            if (input[current] == '(')
            {
                int commentLength = 0;
                if (HttpRuleParser.GetCommentLength(input, current, out commentLength) != HttpParseResult.Parsed)
                {
                    return(0);
                }

                comment = input.Substring(current, commentLength);

                current = current + commentLength;
                current = current + HttpRuleParser.GetWhitespaceLength(input, current);
            }
            else
            {
                // Trailing whitespaces are removed by GetProductLength().
                int productLength = ProductHeaderValue.GetProductLength(input, current, out product);

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

                current = current + productLength;
            }

            parsedValue          = new ProductInfoHeaderValue();
            parsedValue._product = product;
            parsedValue._comment = comment;
            return(current - startIndex);
        }