using System; using System.Collections.Generic; namespace Unosquare.Swan.Networking { /// /// Represents a response from a DNS server. /// public class DnsQueryResult { private readonly List m_AnswerRecords = new List(); private readonly List m_AdditionalRecords = new List(); private readonly List m_AuthorityRecords = new List(); /// /// Initializes a new instance of the class. /// /// The response. internal DnsQueryResult(DnsClient.DnsClientResponse response) : this() { this.Id = response.Id; this.IsAuthoritativeServer = response.IsAuthorativeServer; this.IsRecursionAvailable = response.IsRecursionAvailable; this.IsTruncated = response.IsTruncated; this.OperationCode = response.OperationCode; this.ResponseCode = response.ResponseCode; if(response.AnswerRecords != null) { foreach(DnsClient.IDnsResourceRecord record in response.AnswerRecords) { this.AnswerRecords.Add(new DnsRecord(record)); } } if(response.AuthorityRecords != null) { foreach(DnsClient.IDnsResourceRecord record in response.AuthorityRecords) { this.AuthorityRecords.Add(new DnsRecord(record)); } } if(response.AdditionalRecords != null) { foreach(DnsClient.IDnsResourceRecord record in response.AdditionalRecords) { this.AdditionalRecords.Add(new DnsRecord(record)); } } } private DnsQueryResult() { } /// /// Gets the identifier. /// /// /// The identifier. /// public Int32 Id { get; } /// /// Gets a value indicating whether this instance is authoritative server. /// /// /// true if this instance is authoritative server; otherwise, false. /// public Boolean IsAuthoritativeServer { get; } /// /// Gets a value indicating whether this instance is truncated. /// /// /// true if this instance is truncated; otherwise, false. /// public Boolean IsTruncated { get; } /// /// Gets a value indicating whether this instance is recursion available. /// /// /// true if this instance is recursion available; otherwise, false. /// public Boolean IsRecursionAvailable { get; } /// /// Gets the operation code. /// /// /// The operation code. /// public DnsOperationCode OperationCode { get; } /// /// Gets the response code. /// /// /// The response code. /// public DnsResponseCode ResponseCode { get; } /// /// Gets the answer records. /// /// /// The answer records. /// public IList AnswerRecords => this.m_AnswerRecords; /// /// Gets the additional records. /// /// /// The additional records. /// public IList AdditionalRecords => this.m_AdditionalRecords; /// /// Gets the authority records. /// /// /// The authority records. /// public IList AuthorityRecords => this.m_AuthorityRecords; } }