/// <summary>Asserts that the local name of a given element is the name indicated, and ignores the /// element's contents.</summary> /// <exception cref="XmlException">Thrown when the XML content pointed to by /// <paramref name="xmlReader"/> does not match the indicated <paramref name="elementName"/> and /// <paramref name="options"/>.</exception> /// <param name="xmlReader">The XML reader from which the element shall be read.</param> /// <param name="elementName">Name of the element.</param> /// <param name="options">Options deciding what content to skip.</param> internal static void IgnoreElement(this XmlReader xmlReader, string elementName, IgnoreOptions options) { if (!IsOnElement(xmlReader, elementName)) { if (options.HasFlag(IgnoreOptions.Optional)) { return; } else { throw xmlReader.CreateException(ConverterResources.ExpectedElementNamed, elementName); } } xmlReader.Skip(); if (options.HasFlag(IgnoreOptions.Multiple)) { while (IsOnElement(xmlReader, elementName)) { xmlReader.Skip(); } } }
// ** ISpellParser public CharRange GetNextWord(string text, int start, IgnoreOptions ignore, string previousWord) { // refresh list of comment ranges to check if (text != _text) { _text = text; BuildCommentRangeList(); } // use CharRange implementation by default CharRange range = CharRange.GetNextWord(text, start, ignore, previousWord); if (range == null) { return(null); } // check that the returned range is in the comment list foreach (CharRange r in _commentRanges) { // range is in the list, use it if (r.Start <= range.Start && r.End >= range.End) { return(range); } // range is not in the list, continue with next comment if (r.Start > range.End) { return(GetNextWord(text, r.Start, ignore, previousWord)); } } // done... return(null); }