namespace Unosquare.Swan.Networking { using System.Collections.Generic; /// /// 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() { Id = response.Id; IsAuthoritativeServer = response.IsAuthorativeServer; IsRecursionAvailable = response.IsRecursionAvailable; IsTruncated = response.IsTruncated; OperationCode = response.OperationCode; ResponseCode = response.ResponseCode; if (response.AnswerRecords != null) { foreach (var record in response.AnswerRecords) AnswerRecords.Add(new DnsRecord(record)); } if (response.AuthorityRecords != null) { foreach (var record in response.AuthorityRecords) AuthorityRecords.Add(new DnsRecord(record)); } if (response.AdditionalRecords != null) { foreach (var record in response.AdditionalRecords) AdditionalRecords.Add(new DnsRecord(record)); } } private DnsQueryResult() { } /// /// Gets the identifier. /// /// /// The identifier. /// public int Id { get; } /// /// Gets a value indicating whether this instance is authoritative server. /// /// /// true if this instance is authoritative server; otherwise, false. /// public bool IsAuthoritativeServer { get; } /// /// Gets a value indicating whether this instance is truncated. /// /// /// true if this instance is truncated; otherwise, false. /// public bool IsTruncated { get; } /// /// Gets a value indicating whether this instance is recursion available. /// /// /// true if this instance is recursion available; otherwise, false. /// public bool 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 => m_AnswerRecords; /// /// Gets the additional records. /// /// /// The additional records. /// public IList AdditionalRecords => m_AdditionalRecords; /// /// Gets the authority records. /// /// /// The authority records. /// public IList AuthorityRecords => m_AuthorityRecords; } }