Show / Hide Table of Contents

Class DomainName

A domain name consists of one or more parts, Labels, that are conventionally delimited by dots, such as "example.org".

Inheritance
Object
DomainName
Implements
IEquatable<DomainName>
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.dll
Syntax
public class DomainName : IEquatable<DomainName>
Remarks

Equality is based on the number of and the case-insenstive contents of Labels.

Constructors

| Improve this Doc View Source

DomainName(String)

Creates a new instance of the DomainName class from the specified name.

Declaration
public DomainName(string name)
Parameters
Type Name Description
String name

The dot separated labels; such as "example.org".

Remarks

The name can contain backslash to escape a character. See RFC 4343 for the character escaping rules.

note

To use us backslash in a domain name (highly unusaual), you must use a double backslash.

| Improve this Doc View Source

DomainName(String[])

Creates a new instance of the DomainName class from the sequence of label.

Declaration
public DomainName(params string[] labels)
Parameters
Type Name Description
String[] labels

The Labels.

Remarks

The labels are not parsed; character escaping is not performed.

Fields

| Improve this Doc View Source

Root

The root name space.

Declaration
public static DomainName Root
Field Value
Type Description
DomainName

The empty string.

Remarks

The DNS is a hierarchical naming system for computers, services, or any resource participating in the Internet. The top of that hierarchy is the root domain. The root domain does not have a formal name and its label in the DNS hierarchy is an empty string.

Properties

| Improve this Doc View Source

Labels

A sequence of labels that make up the domain name.

Declaration
public IReadOnlyList<string> Labels { get; }
Property Value
Type Description
IReadOnlyList<String>

A sequece of strings.

Remarks

The last label is the TLD (top level domain).

Methods

| Improve this Doc View Source

BelongsTo(DomainName)

Determines if this domain name is a subdomain of or equals an another domain name.

Declaration
public bool BelongsTo(DomainName domain)
Parameters
Type Name Description
DomainName domain

Another domain.

Returns
Type Description
Boolean

true if this domain name is a subdomain of domain or equals domain.

| Improve this Doc View Source

Equals(DomainName)

Declaration
public bool Equals(DomainName that)
Parameters
Type Name Description
DomainName that
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
Object.Equals(Object)
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
Overrides
Object.GetHashCode()
| Improve this Doc View Source

IsSubdomainOf(DomainName)

Determines if this domain name is a subdomain of another domain name.

Declaration
public bool IsSubdomainOf(DomainName domain)
Parameters
Type Name Description
DomainName domain

Another domain.

Returns
Type Description
Boolean

true if this domain name is a subdomain of domain.

| Improve this Doc View Source

Join(DomainName[])

Combine multiple domain names to form one.

Declaration
public static DomainName Join(params DomainName[] names)
Parameters
Type Name Description
DomainName[] names

The domain names to join.

Returns
Type Description
DomainName

A new domain containing all the names.

| Improve this Doc View Source

LabelsEqual(String, String)

Determines if the two domain name labels are equal.

Declaration
public static bool LabelsEqual(string a, string b)
Parameters
Type Name Description
String a

A domain name label

String b

A domain name label

Returns
Type Description
Boolean

true if a and b are considered equal.

Remarks

Uses a case-insenstive algorithm, where 'A-Z' are equivalent to 'a-z'.

| Improve this Doc View Source

Parent()

Gets the parent's domain name.

Declaration
public DomainName Parent()
Returns
Type Description
DomainName

The domain name of the parent or null if there is no parent; e.g. this is the root.

| Improve this Doc View Source

ToCanonical()

Gets the canonical form of the domain name.

Declaration
public DomainName ToCanonical()
Returns
Type Description
DomainName

A domain name in the canonical form.

Remarks

All uppercase US-ASCII letters in the Labels are replaced by the corresponding lowercase US-ASCII letters.

| Improve this Doc View Source

ToString()

Returns the textual representation.

Declaration
public override string ToString()
Returns
Type Description
String

The concatenation of the Labels separated by a dot.

Overrides
Object.ToString()
Remarks

If a label contains a dot or backslash, then it is escaped with a backslash.

Operators

| Improve this Doc View Source

Equality(DomainName, DomainName)

Value equality.

Declaration
public static bool operator ==(DomainName a, DomainName b)
Parameters
Type Name Description
DomainName a
DomainName b
Returns
Type Description
Boolean
| Improve this Doc View Source

Implicit(String to DomainName)

Implicit casting of a String to a DomainName.

Declaration
public static implicit operator DomainName(string s)
Parameters
Type Name Description
String s

A possibly escaped domain name.

Returns
Type Description
DomainName

A new DomainName

Remarks

Equivalent to

new DomainName(s)

| Improve this Doc View Source

Inequality(DomainName, DomainName)

Value inequality.

Declaration
public static bool operator !=(DomainName a, DomainName b)
Parameters
Type Name Description
DomainName a
DomainName b
Returns
Type Description
Boolean

Implements

System.IEquatable<T>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX