C1.Silverlight.SpellChecker Namespace > C1SpellChecker Class : CustomParser Property |
'Declaration
Public Property CustomParser As ISpellParser
public ISpellParser CustomParser {get; set;}
This property allows you to specify a custom parser for breaking up text into words to be spell-checked.
For example, you may want to use a custom parser when checking source code files. This way you can spell-check the comments in the code and skip the actual code.
public class Parser : C1.Win.C1SpellChecker.ISpellParser { CharRange ISpellParser.GetNextWord(string text, int start, IgnoreOptions ignore, string previousWord) { // start with default implementation CharRange range = CharRange.GetNextWord(text, start, ignore, previousWord); // additional logic to handle underscores and mixed-case if (range != null) { // get original word string word = range.Text; // split word at underscores int index = word.IndexOf('_'); if (index > -1) { word = word.Substring(0, index); range = new CharRange(word, range.Start, word == previousWord); } // split MixedCasedWords for (int i = 1; i < word.Length; i++) { if (char.IsUpper(word[i]) && char.IsLower(word[i - 1])) { word = word.Substring(0, i); range = new CharRange(word, range.Start, word == previousWord); } } } // done return range; } string ISpellParser.FilterWord(string word) { return word; } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2