private static bool FilterMatches(
string nameToCheck,
string filter,
bool caseSensitiveComparison)
{
bool bResult = false;
if( string.IsNullOrEmpty( nameToCheck ) )
{
// No name given, so the call must fail.
return false;
}
if( string.IsNullOrEmpty( filter ) )
{
// No filter given, so the given name passes the test
return true;
}
if( !caseSensitiveComparison )
{
// Since the String.Contains function only does case-sensitive checks,
// cheat with our copies of the values which we'll use for the comparison.
nameToCheck = nameToCheck.ToUpper();
filter = filter.ToUpper();
}
bResult = nameToCheck.Contains( filter );
return bResult;
}