/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public ProcessMatchedPairTokens(IChecksDataSource checksDataSource, MatchedPairList pairList, StyleCategorizer styleCategorizer) { m_checksDataSource = checksDataSource; m_pairList = pairList; m_styleCategorizer = styleCategorizer; }
public void ValidateMatchedPairs_InvalidEntries() { PunctuationDlg punctDlg = new PunctuationDlg(); MatchedPairList pairList = new MatchedPairList(); MatchedPair pair = new MatchedPair(); pair.Close = ")"; pairList.Add(pair); bool result = ReflectionHelper.GetBoolResult(punctDlg, "ValidateMatchedPairs", new object[] {pairList, false}); Assert.IsFalse(result); }
public void ValidateMatchedPairs_ValidEntries() { using (var punctDlg = new PunctuationDlg()) { var pairList = new MatchedPairList(); var pair = new MatchedPair { Open = "(", Close = ")" }; pairList.Add(pair); bool result = ReflectionHelper.GetBoolResult(punctDlg, "ValidateMatchedPairs", new object[] { pairList, false }); Assert.IsTrue(result); } }
public void ValidateMatchedPairs_InvalidEntries() { PunctuationDlg punctDlg = new PunctuationDlg(); MatchedPairList pairList = new MatchedPairList(); MatchedPair pair = new MatchedPair(); pair.Close = ")"; pairList.Add(pair); bool result = ReflectionHelper.GetBoolResult(punctDlg, "ValidateMatchedPairs", new object[] { pairList, false }); Assert.IsFalse(result); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public List <TextTokenSubstring> GetReferences(IEnumerable <ITextToken> tokens, string desiredKey) { #if DEBUG List <ITextToken> AllTokens = new List <ITextToken>(tokens); if (AllTokens.Count == 0) { // Keep the compiler from complaining about assigning to a variable, but not using it. } #endif // m_characterCategorizer = m_checksDataSource.CharacterCategorizer; ValidItems = m_checksDataSource.GetParameterValue(kValidItemsParameter); InvalidItems = m_checksDataSource.GetParameterValue(kInvalidItemsParameter); string preferredLocale = m_checksDataSource.GetParameterValue("PreferredLocale") ?? string.Empty; string poeticStyles = m_checksDataSource.GetParameterValue("PoeticStyles"); string introductionOutlineStyles = m_checksDataSource.GetParameterValue("IntroductionOutlineStyles"); MatchedPairList pairList = MatchedPairList.Load(m_checksDataSource.GetParameterValue("MatchedPairs"), m_checksDataSource.GetParameterValue("DefaultWritingSystemName")); StyleCategorizer styleCategorizer = new StyleCategorizer(poeticStyles, introductionOutlineStyles); ProcessMatchedPairTokens bodyProcessor = new ProcessMatchedPairTokens( m_checksDataSource, pairList, styleCategorizer); ProcessMatchedPairTokens noteProcessor = new ProcessMatchedPairTokens( m_checksDataSource, pairList, styleCategorizer); m_unmatchedPairs = new List <TextTokenSubstring>(); foreach (ITextToken tok in tokens) { if (tok.Text == null || (tok.Locale ?? string.Empty) != preferredLocale) { continue; } if (tok.TextType == TextType.Note) { // if a new note is starting finalize any sequences from the previous note if (tok.IsNoteStart) { noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs); } noteProcessor.ProcessToken(tok, desiredKey, m_unmatchedPairs); } else if (tok.TextType == TextType.Verse || tok.TextType == TextType.Other || tok.IsParagraphStart) { // body text: finalize any note that was in progress and continue with body text noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs); bodyProcessor.ProcessToken(tok, desiredKey, m_unmatchedPairs); } } noteProcessor.FinalizeResult(desiredKey, m_unmatchedPairs); bodyProcessor.FinalizeResult(desiredKey, m_unmatchedPairs); return(m_unmatchedPairs); }
public void FixtureSetup() { m_pairList = MatchedPairList.Load(kXml, "Test WS"); }