private void FindMatches(IEnumerable <string> parts, DomainDataStructure structure, List <TldRule> matches) { if (structure.TldRule != null) { matches.Add(structure.TldRule); } var part = parts.FirstOrDefault(); if (string.IsNullOrEmpty(part)) { return; } DomainDataStructure foundStructure; if (structure.Nested.TryGetValue(part, out foundStructure)) { FindMatches(parts.Skip(1), foundStructure, matches); } if (structure.Nested.TryGetValue("*", out foundStructure)) { FindMatches(parts.Skip(1), foundStructure, matches); } }
private void AddRules(IEnumerable <TldRule> tldRules) { System.Diagnostics.Debug.Assert(_domainDataStructure == null); //We can only load rules once _domainDataStructure = new DomainDataStructure("*", new TldRule("*")); foreach (var tldRule in tldRules) { this.AddRule(tldRule); } }