public static bool Apply(this PathFilter pathFilter, string path) { switch (pathFilter.FilterPatternType) { case FilterPatternType.Glob: return(pathFilter.GetSafeGlob().IsMatch(path)); case FilterPatternType.Regexp: return(pathFilter.GetSafeRegexp().IsMatch(path)); default: throw new ArgumentException(String.Format("FilterPatternType {0} not supported", (int)pathFilter.FilterPatternType), "pathFilter.FilterPatternType"); } }