Repository navigation
Expand file tree
/
Copy pathDnsQuestion.cs
More file actions
79 lines (72 loc) · 2.97 KB
/
Copy pathDnsQuestion.cs
File metadata and controls
79 lines (72 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
namespace DnsClient
{
/// <summary>
/// The <see cref="DnsQuestion"/> class transports information of the lookup query performed by <see cref="IDnsQuery"/>.
/// <para>
/// A list of questions is returned by <see cref="IDnsQueryResponse"/> (although, the list will always contain only one <see cref="DnsQuestion"/>).
/// </para>
/// </summary>
public class DnsQuestion
{
/// <summary>
/// Gets the domain name the lookup was runnig for.
/// </summary>
/// <value>
/// The name of the query.
/// </value>
public DnsString QueryName { get; }
/// <summary>
/// Gets the question class.
/// </summary>
/// <value>
/// The question class.
/// </value>
public QueryClass QuestionClass { get; }
/// <summary>
/// Gets the type of the question.
/// </summary>
/// <value>
/// The type of the question.
/// </value>
public QueryType QuestionType { get; }
/// <summary>
/// Initializes a new instance of the <see cref="DnsQuestion"/> class.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="questionType">Type of the question.</param>
/// <param name="questionClass">The question class.</param>
/// <exception cref="ArgumentNullException">If <paramref name="query"/> is null.</exception>
public DnsQuestion(string query, QueryType questionType, QueryClass questionClass = QueryClass.IN)
: this(DnsString.Parse(query), questionType, questionClass)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DnsQuestion"/> class.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="questionType">Type of the question.</param>
/// <param name="questionClass">The question class.</param>
/// <exception cref="ArgumentNullException">If <paramref name="query"/> is null.</exception>
public DnsQuestion(DnsString query, QueryType questionType, QueryClass questionClass = QueryClass.IN)
{
QueryName = query ?? throw new ArgumentNullException(nameof(query));
QuestionType = questionType;
QuestionClass = questionClass;
}
/// <inheritdoc />
public override string ToString()
{
return ToString(0);
}
/// <summary>
/// Returns the information of this instance in a friendly format with an optional <paramref name="offset"/>.
/// </summary>
/// <param name="offset">The optional offset which can be used for pretty printing.</param>
/// <returns>The string representation of this instance.</returns>
public string ToString(int offset = -32)
{
return string.Format("{0," + offset + "} \t{1} \t{2}", QueryName.Original, QuestionClass, QuestionType);
}
}
}