Exemplo n.º 1
0
        public RelativePathMatcher Read(MatchElement filter)
        {
            var matcherCount = 0;
            var matcher      = new RelativePathMatcher(filter.Rule);

            if (filter.Regex != null)
            {
                matcherCount++;
                matcher = TryReadRegex(filter);
            }
            if (filter.Glob != null)
            {
                matcherCount++;
                matcher = TryReadGlob(filter);
            }
            if (filter.Extension != null)
            {
                matcherCount++;
                matcher = TryReadExtension(filter);
            }
            if (matcherCount > 1)
            {
                errors.Record(new MultipleMatchersSpecified()).SetLocation(filter.ElementInformation);
            }
            return(matcher);
        }
Exemplo n.º 2
0
 private RelativePathMatcher TryReadRegex(MatchElement filter)
 {
     try
     {
         var regex = FileSystemRegexHelpers.CreateRegex(filter.Regex, casing);
         return(new RelativePathMatcher(regex, filter.Rule, $"Regex({filter.Regex})"));
     }
     catch (Exception ex)
     {
         errors.Record(new InvalidFilterRegex(filter.Regex, ex.Message)).SetLocation(filter.ElementInformation);
         return(default);