internal static NameServerCollection Create( IEnumerable <DnsClient.DNS.RR> records, IEnumerable <DnsClient.DNS.RR> addresses = null) { // NS records from Authority Section IEnumerable <DnsClient.DNS.Records.NS> nsRecords = records.Select <DnsClient.DNS.Records.NS>(); DnsClient.DNS.Records.NS ns1 = nsRecords.FirstOrDefault(); if (ns1 == null) { return(Empty); } // There are NS RRs. NameServerCollection result = new NameServerCollection( (DnsDomain)ns1.Base.NAME, nsRecords.Select(ns => new NameServer( (DnsDomain)ns.Base.NAME, (DnsDomain)ns.NSDNAME))); // Apply address records from Additional Section (A or AAAA) if any if (addresses != null) { foreach (DnsClient.DNS.Records.Address addr in addresses.Select( rr => rr as DnsClient.DNS.Records.Address).Where(a => a != null)) { DnsDomain name = DnsDomain.Parse(addr.Base.NAME); if (result.NameServers.ContainsKey(name)) { result.NameServers[name].Addresses.Add(addr.ADDRESS); } } } return(result); }
public NetworkHost(string name) { if (name == null) { throw new ArgumentNullException("name", "Value cannot be null."); } _Name = DnsDomain.Parse(name); _Addresses = new List <IPAddress>(); }