Skip to content

HierarchicalKey Methods

An immutable, ordinal application identity formed from nonempty hierarchical segments.

Append(HierarchicalKey)

View source
public HierarchicalKey Append(HierarchicalKey suffix)
Composes this hierarchy with an already constructed suffix hierarchy.

Parameters

suffixHierarchicalKey
The constructed suffix.

Returns

A flat concatenated identity preserving both paths' segment boundaries.

Exceptions

System.InvalidOperationException
This key is unset.
System.ArgumentException
suffix is unset.

Create(ReadOnlySpan<string>)

static
View source
public static HierarchicalKey Create(params ReadOnlySpan<string> values)
Creates a hierarchy from literal segments in root-first order.

Parameters

valuesReadOnlySpan<string>
The nonempty literal segments.

Returns

A flat canonical identity which owns its immutable backing string.

Exceptions

System.ArgumentNullException
A segment is null.
System.ArgumentException
The input or a segment is empty, or a segment contains an unpaired surrogate.

Create(string)

static
View source
public static HierarchicalKey Create(string value)
Creates one literal segment, escaping slash and backslash characters.

Parameters

valuestring
The nonempty literal segment.

Returns

The segment identity.

Exceptions

System.ArgumentNullException
value is null.
System.ArgumentException
value is empty or contains an unpaired surrogate.

CreateChildKey(string)

View source
public HierarchicalKey CreateChildKey(string value)
Appends one literal child segment.

Parameters

valuestring
The nonempty literal child segment.

Returns

The child identity.

Exceptions

System.InvalidOperationException
This key is unset.
System.ArgumentNullException
value is null.
System.ArgumentException
value is empty or contains an unpaired surrogate.

Equals(HierarchicalKey)

View source
public bool Equals(HierarchicalKey other)
Indicates whether the current object is equal to another object of the same type.

Parameters

otherHierarchicalKey
An object to compare with this object.

Returns

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

override
View source
public override bool Equals(object? obj)
Indicates whether this instance and a specified object are equal.

Parameters

objobject?
The object to compare with the current instance.

Returns

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetEnumerator

View source
public SegmentEnumerator GetEnumerator()
Enumerates escaped canonical segment spans in root-first order.

Returns

An allocation-free segment enumerator.

GetHashCode

override
View source
public override int GetHashCode()
Returns the hash code for this instance.

Returns

A 32-bit signed integer that is the hash code for this instance.

GetParent

View source
public HierarchicalKey? GetParent()
Gets the immediate parent, or null for a root or unset key.

Returns

The parent identity when this key has more than one segment.

IsAncestorOf(HierarchicalKey)

View source
public bool IsAncestorOf(HierarchicalKey other)
Tests whether this key is equal to or an ancestor of the other key.

Parameters

otherHierarchicalKey
The identity to inspect.

Returns

Whether the full prefix consists of equal ordinal segments. Unset keys return false.

IsChildOf(HierarchicalKey)

View source
public bool IsChildOf(HierarchicalKey other)
Tests whether this key is the other's immediate child.

Parameters

otherHierarchicalKey
The potential parent.

Returns

Whether there is exactly one additional segment.

IsParentOf(HierarchicalKey)

View source
public bool IsParentOf(HierarchicalKey other)
Tests whether this key is the other's immediate parent.

Parameters

otherHierarchicalKey
The potential child.

Returns

Whether the other key extends this key by exactly one segment.

Parse(ReadOnlySpan<char>, IFormatProvider?)

static
View source
public static HierarchicalKey Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
Parses a span of characters into a value.

Parameters

sReadOnlySpan<char>
The span of characters to parse.
providerIFormatProvider?
An object that provides culture-specific formatting information about s.

Returns

The result of parsing s.

Exceptions

System.FormatException
s is not in the correct format.
System.OverflowException
s is not representable by TSelf.

Parse(string, IFormatProvider?)

static
View source
public static HierarchicalKey Parse(string s, IFormatProvider? provider = null)
Parses a string into a value.

Parameters

sstring
The string to parse.
providerIFormatProvider?
An object that provides culture-specific formatting information about s.

Returns

The result of parsing s.

Exceptions

System.ArgumentNullException
s is null.
System.FormatException
s is not in the correct format.
System.OverflowException
s is not representable by TSelf.

ToString

override
View source
public override string ToString()
Returns the fully qualified type name of this instance.

Returns

The fully qualified type name.

ToString(string?, IFormatProvider?)

View source
public string ToString(string? format, IFormatProvider? formatProvider)
Formats the value of the current instance using the specified format.

Parameters

formatstring?
The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the System.IFormattable implementation.
formatProviderIFormatProvider?
The provider to use to format the value. -or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

The value of the current instance in the specified format.

TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)

View source
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Tries to format the value of the current instance into the provided span of characters.

Parameters

destinationSpan<char>
The span in which to write this instance's value formatted as a span of characters.
charsWrittenint
When this method returns, contains the number of characters that were written in destination.
formatReadOnlySpan<char>
A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.
providerIFormatProvider?
An optional object that supplies culture-specific formatting information for destination.

Returns

true if the formatting was successful; otherwise, false.

TryParse(ReadOnlySpan<char>, IFormatProvider?, HierarchicalKey)

static
View source
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out HierarchicalKey result)
Tries to parse a span of characters into a value.

Parameters

sReadOnlySpan<char>
The span of characters to parse.
providerIFormatProvider?
An object that provides culture-specific formatting information about s.
resultHierarchicalKey
When this method returns, contains the result of successfully parsing s, or an undefined value on failure.

Returns

true if s was successfully parsed; otherwise, false.

TryParse(string?, IFormatProvider?, HierarchicalKey)

static
View source
public static bool TryParse(string? s, IFormatProvider? provider, out HierarchicalKey result)
Tries to parse a string into a value.

Parameters

sstring?
The string to parse.
providerIFormatProvider?
An object that provides culture-specific formatting information about s.
resultHierarchicalKey
When this method returns, contains the result of successfully parsing s or an undefined value on failure.

Returns

true if s was successfully parsed; otherwise, false.

operator ==(HierarchicalKey, HierarchicalKey)

static
View source
public static bool operator ==(HierarchicalKey left, HierarchicalKey right)
Compares complete ordinal key values.

Parameters

leftHierarchicalKey
The first identity.
rightHierarchicalKey
The second identity.

Returns

Whether the identities are equal.

operator !=(HierarchicalKey, HierarchicalKey)

static
View source
public static bool operator !=(HierarchicalKey left, HierarchicalKey right)
Compares complete ordinal key values for inequality.

Parameters

leftHierarchicalKey
The first identity.
rightHierarchicalKey
The second identity.

Returns

Whether the identities differ.