BuildingCoder.NestedFamilyFunctions.FilterMatches C# (CSharp) Метод

FilterMatches() приватный статический Метод

Returns whether or not the nameToCheck matches the given filter. This is done with a simple Contains check, so wildcards won't work.
private static FilterMatches ( string nameToCheck, string filter, bool caseSensitiveComparison ) : bool
nameToCheck string The name (e.g. type name or family file name) to check for a match with the filter
filter string The filter to compare to
caseSensitiveComparison bool Whether or not the comparison is case-sensitive.
Результат bool
        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;
        }