コード例 #1
0
        private bool IsMatch(string glob, string fileName, string directory)
        {
            var matcher = new EditorConfigMinimatcher(glob, _globOptions);
            var isMatch = matcher.IsMatch(fileName);

            Debug.WriteLine("{0} :: {1} \t\t:: {2}", isMatch ? "?" : "?", glob, fileName);
            return(isMatch);
        }
コード例 #2
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, EditorConfigMinimatcherOptions options = null)
        {
            var mm = new EditorConfigMinimatcher(pattern, options);

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

            var m = new EditorConfigMinimatcher(pattern, options);

            return(m.IsMatch);
        }