示例#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, Options options = null)
        {
            var mm = new Minimatcher(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, Options options = null)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            // "" only matches ""
            if (String.IsNullOrWhiteSpace(pattern))
            {
                return(String.IsNullOrEmpty);
            }

            var m = new Minimatcher(pattern, options);

            return(m.IsMatch);
        }
示例#3
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, Options options = null)
 {
     var mm = new Minimatcher(pattern, options);
     list = list.Where(mm.IsMatch);
     if (options != null && options.NoNull)
         list = list.DefaultIfEmpty(pattern);
     return list;
 }
示例#4
0
        ///<summary>Creates a filter function that tests input against a pattern.</summary>
        public static Func<string, bool> CreateFilter(string pattern, Options options = null)
        {
            if (pattern == null) throw new ArgumentNullException("pattern");
            // "" only matches ""
            if (String.IsNullOrWhiteSpace(pattern)) return String.IsNullOrEmpty;

            var m = new Minimatcher(pattern, options);
            return m.IsMatch;
        }