Example #1
0
        private bool TryReadQuotedValue(out int startIndex, out int length)
        {
            startIndex = -1;
            length     = 0;

            if (remainingChars == StringSegment.Empty)
            {
                return(false);
            }

            startIndex = SipCharacters.IndexOfNonWhitespace(remainingChars);

            if (startIndex < 0)
            {
                return(false);
            }

            if (remainingChars[startIndex] != QuoteChar)
            {
                return(false);
            }

            var endQuoteCharIndex = SipCharacters.IndexOfNonEscaped(remainingChars, QuoteChar, startIndex + 1);

            if (endQuoteCharIndex < 0)
            {
                return(false);
            }

            length = endQuoteCharIndex - startIndex;
            return(true);
        }
        private static bool TryReadQuotedDisplayName(StringSegment chars, out int startIndex, out int length)
        {
            startIndex = -1;
            length     = 0;

            if (chars == StringSegment.Empty)
            {
                return(false);
            }

            startIndex = SipCharacters.IndexOfNonWhitespace(chars);

            if (startIndex < 0)
            {
                return(false);
            }

            if (chars[startIndex] != QuoteChar)
            {
                return(false);
            }

            var endQuoteCharIndex = SipCharacters.IndexOfNonEscaped(chars, QuoteChar, startIndex + 1);

            if (endQuoteCharIndex < 0)
            {
                return(false);
            }

            length = endQuoteCharIndex - startIndex;
            return(true);
        }