private bool matchPrefix(String prefix, String word)
{
if (!Common.AppPreferences.WordPredictionFilterMatchPrefix)
{
return true;
}
prefix = prefix.Trim();
if (String.IsNullOrEmpty(prefix))
{
return true;
}
int numCharsToMatch = prefix.Length - Common.AppPreferences.WordPredictionFilterMatchPrefixLengthAdjust;
if (numCharsToMatch <= 0)
numCharsToMatch = prefix.Length;
if (numCharsToMatch > 0)
{
if (word.Length > numCharsToMatch)
word = word.Substring(0, numCharsToMatch);
if (prefix.Length > numCharsToMatch)
prefix = prefix.Substring(0, numCharsToMatch);
}
return (word.Length > prefix.Length) ?
word.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase) :
prefix.StartsWith(word, StringComparison.InvariantCultureIgnoreCase);
}