예제 #1
0
        ///<summary>Filters a list of inputs against a single pattern.</summary>
        ///<remarks>This function reparses this input on each invocation.  For performance, avoid this function and reuse a Minimatcher instance instead.</remarks>
        public static IEnumerable <string> Filter(IEnumerable <string> list, string pattern, GlobMatcherOptions options = null)
        {
            var mm = new GlobMatcher(pattern, options);

            list = list.Where(mm.IsMatch);
            if (options != null && options.NoNull)
            {
                list = list.DefaultIfEmpty(pattern);
            }
            return(list);
        }
예제 #2
0
        ///<summary>Creates a filter function that tests input against a pattern.</summary>
        public static Func <string, bool> CreateFilter(string pattern, GlobMatcherOptions options = null)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            // "" only matches ""
            if (String.IsNullOrWhiteSpace(pattern))
            {
                return(String.IsNullOrEmpty);
            }

            var m = new GlobMatcher(pattern, options);

            return(m.IsMatch);
        }