internal static DomainValue ResolveSubdomain(string[] domainparts, DomainValue value) { if (domainparts.Length > 2) // sub-domain { for (int i = domainparts.Length - 3; i >= 0; i--) { if (string.IsNullOrWhiteSpace(domainparts[i])) { value = null; break; } var sub = value.GetMap(domainparts[i]); if (sub == null) sub = value.GetMap("*"); if (sub == null) break; value = sub; } } return value; }
public void ReadMaps() { var domain = new DomainValue(Example_2_5_generic); var www = domain.GetMap("www"); var wwwAlias = www.Alias; Assert.AreEqual("", wwwAlias); var ftp = domain.GetMap("ftp"); var ftpIp = ftp.Ips.Select(m => m.ToString()); Assert.AreEqual("10.2.3.4", ftpIp.First()); Assert.AreEqual("10.4.3.2", ftpIp.Skip(1).First()); var mail = domain.GetMap("mail"); var mailNs = mail.Ns; Assert.AreEqual("ns1.host.net", mailNs.First()); Assert.AreEqual("ns12.host.net", mailNs.Skip(1).First()); var none = domain.GetMap("none"); Assert.IsNull(none); }