in src/cs/Microsoft.PhoneticMatching/Matchers/FuzzyMatcher/AbstractFuzzyMatcher.cs [321:365]
private Pronounceable GetPronounceableAt(int idx)
{
Pronounceable pronounceable;
if (idx == -1)
{
pronounceable = this.currentQuery;
}
else
{
if (idx >= this.targets.Count)
{
throw new ArgumentOutOfRangeException(string.Format("index is out of bound : idx={0} - targets.Count={1}", idx, this.targets.Count));
}
// lazy initialize this.pronounceables[idx]
if (this.pronounceables[idx] == null)
{
// lazy initialize this.extractions[idx]
if (this.extractions[idx] == null)
{
if (this.targetToExtraction == null)
{
throw new InvalidOperationException(string.Format("Conversion delegate is required to retrieve extraction from Target type [{0}] to Extraction type [{1}].", typeof(Target), typeof(Extraction)));
}
this.extractions[idx] = this.targetToExtraction(this.targets[idx]);
}
// check if extraction and pronounceable points to the same object
if (this.pronounceables[idx] == null)
{
if (this.extractionToPronounceable == null)
{
throw new InvalidOperationException(string.Format("Conversion delegate is required to retrieve extraction from Target type [{0}] to Extraction type [{1}].", typeof(Extraction), typeof(Pronounceable)));
}
this.pronounceables[idx] = this.extractionToPronounceable(this.extractions[idx]);
}
}
pronounceable = this.pronounceables[idx];
}
return pronounceable;
}