Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        private void AddRules(IEnumerable <TldRule> tldRules)
        {
            this._domainDataStructure = new DomainDataStructure("*", this._rootTldRule);

            foreach (var tldRule in tldRules)
            {
                this.AddRule(tldRule);
            }
        }
Beispiel #3
0
        public void AddRules(IEnumerable <TldRule> tldRules)
        {
            this._domainDataStructure = new DomainDataStructure("*", new TldRule("*"));

            foreach (var tldRule in tldRules)
            {
                this.AddRule(tldRule);
            }
        }
 /// <summary>
 /// Creates a DomainParser based on an already initialzed tree.
 /// </summary>
 /// <param name="initializedDataStructure">An already initialized tree.</param>
 /// <param name="domainNormalizer">An <see cref="IDomainNormalizer"/>.</param>
 public DomainParser(DomainDataStructure initializedDataStructure, IDomainNormalizer domainNormalizer = null)
     : this(domainNormalizer)
 {
     this._domainDataStructure = initializedDataStructure;
 }
        private void AddRules(IEnumerable <TldRule> tldRules)
        {
            this._domainDataStructure = this._domainDataStructure ?? new DomainDataStructure("*", this._rootTldRule);

            this._domainDataStructure.AddRules(tldRules);
        }