/// <summary> /// 获取域名服务信息 /// </summary> /// <param name="domain">域名</param> /// <returns>域名服务信息</returns> public TmphDomainServer Get(TmphSubArray<byte> domain) { var data = this.data; if (domain.Count != 0 && data.Data != null) { var index = new TmphSearcher(data).Search(domain); if (index >= 0) return Servers[index]; } return null; }
/// <summary> /// 删除域名服务信息 /// </summary> /// <param name="domain"></param> /// <param name="server">域名服务信息</param> /// <returns></returns> public TmphDomainSearcher Remove(byte[] domain, out TmphDomainSearcher removeDomains, out TmphDomainServer server) { var domains = this.domains; var servers = Servers; var data = this.data; if (data.Data != null && domain.Length != 0) { var index = new TmphSearcher(data).Search(domain); if (index >= 0) { var searcher = Default; if (domains.Length != 1) { var length = domains.Length - 1; var newDomains = new byte[length][]; var newServers = new TmphDomainServer[length]; Array.Copy(domains, 0, newDomains, 0, index); Array.Copy(servers, 0, newServers, 0, index); Array.Copy(domains, index + 1, newDomains, index, length - index); Array.Copy(servers, index + 1, newServers, index, length - index); searcher = new TmphDomainSearcher(newDomains, newServers); } server = servers[index]; removeDomains = this; return searcher; } } server = null; removeDomains = null; return this; }