protected LibraryMatcher ParseLibraryOrGroupMatcher(string search) { LibraryMatcher proj = new ConfigParser().ParseLibraryMatcher(search, new ConfigLocation(1, search)); List<Func<string, bool>> ms = Matchers.CreateStringMatchers(search); LibraryMatcher group = (l, r) => l.GroupElement != null && ms.Any(m => m(l.GroupElement.Name)); return (l, r) => proj(l, r) || group(l, r); }
private static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Use: dependency-checker <config file>"); Console.WriteLine(); return -1; } try { var warnings = new List<OutputEntry>(); Config config = new ConfigParser().Parse(args[0]); DependencyGraph graph = ProjectsLoader.LoadGraph(config, warnings); new GroupsLoader(config, graph, warnings).FillGroups(); ArchitectureGraph architecture = ArchitectureLoader.Load(config, graph); warnings.AddRange(RulesMatcher.Match(graph, config.Rules)); warnings = warnings.Where(e => !(e is DependencyRuleMatch) || !((DependencyRuleMatch) e).Allowed) .Where(w => !config.InOutput.Ignore.Any(f => f(w))) .ToList(); DumpProjects(graph.Vertices, config.Output.Projects); DumpGroups(graph.Vertices, config.Output.Groups); config.Output.Results.ForEach(o => o.Output(warnings)); config.Output.Dependencies.ForEach(o => o.Output(graph, architecture, warnings)); config.Output.Architecture.ForEach(o => o.Output(architecture, warnings)); DumpNumberOfErrorsFound(warnings); Console.WriteLine(); return warnings.Count(w => w.Severity == Severity.Error); } catch (ConfigParserException e) { Console.WriteLine("Error parsing config file: " + e.Message); Console.WriteLine(); return -1; } catch (ConfigException e) { Console.WriteLine("Error: " + e.Message); Console.WriteLine(); return -1; } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(); return -1; } }