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;
}
}