using System.Collections.Generic; using Ubiety.Dns.Core.Common; namespace Ubiety.Dns.Core { /// /// DNS request /// public class Request { private readonly List _questions; /// /// Initializes a new instance of the class /// public Request() { Header = new Header { OpCode = OperationCode.Query, QuestionCount = 0 }; _questions = new List(); } /// /// Gets the DNS record header /// public Header Header { get; } /// /// Gets the request as a byte array /// /// Byte array of the data public byte[] GetData() { var data = new List(); Header.QuestionCount = (ushort)_questions.Count; data.AddRange(Header.GetData()); foreach (var q in _questions) { data.AddRange(q.GetData()); } return data.ToArray(); } /// /// Add a question to the request /// /// Question to add to the request public void AddQuestion(Question question) { _questions.Add(question); } } }