public bool GetValueExtents(string tagString, int valueStartPosition, ref XmlParserCursor cursor) { if (tagString[valueStartPosition] != '"') { cursor.Invalidate(); } else { // Skip the opening quote. cursor.StartPosition = valueStartPosition + 1; // The attribute value starts with '"'. The returned string will be unquoted. int valueEndPos = FindExpectedChar(tagString, '"', cursor.StartPosition + 1); while (valueEndPos != -1) { bool isEscaped = false; int testChar = valueEndPos - 1; while (testChar >= 0 && tagString[testChar] == '\\') { isEscaped = !isEscaped; testChar--; } // If the quote is escaped with '\\', keep on searching for an non-escaped quote. if (isEscaped) { valueEndPos = FindExpectedChar(tagString, '"', valueEndPos + 1); } else { break; } } if (valueEndPos == -1) { cursor.Invalidate(); } else { cursor.EndPosition = valueEndPos; } } return(cursor.IsValid); }
private bool Invalidate() { nameCursor.Invalidate(); valueCursor.Invalidate(); return(false); }
/// <summary> /// Invalidates the parser so that it cannot be used until reset. The method /// returns a constant 'false' value, so that it can be used directly on 'return' /// statement. For example: return Invalidate(). /// </summary> /// <returns>Always returns false.</returns> bool Invalidate() { _cursor.Invalidate(); _path.Clear(); return(false); }