Struct ValueList<T>
Represents an immutable list of parsable values that can be used as a route path parameter, query string parameter, or as a property in an IRouteParamsModel<TSelf>. Implements IParsable<TSelf> and IEquatable<T>.
Namespace: Singulink.UI.Navigation
Assembly: Singulink.UI.Navigation.dll
Syntax
public readonly struct ValueList<T> : IParsable<ValueList<T>>, IEquatable<ValueList<T>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : notnull, IParsable<T>, IEquatable<T>
Type Parameters
| Name | Description |
|---|---|
| T | The element type. Must implement IParsable<TSelf> and IEquatable<T>. |
Remarks
The string representation uses one of two URI-safe encodings, chosen so that structural delimiters do not require URI escaping:
-
Tilde-separated: a leading tilde (
~) followed by values separated by tildes, e.g.~1~2~3. Used when no value contains a tilde. -
Length-prefixed: each value is written as
{length}~{value}, e.g.5~hello5~world. Used when any value contains a tilde, and as the safe fallback for non-whitelisted element types.
An empty string parses to an empty list. The first character of the input selects the decoder.
Constructors
| Name | Description |
|---|---|
| ValueList(IEnumerable<T>) | Initializes a new instance of the ValueList<T> struct with the items from the specified sequence. |
| ValueList(ImmutableArray<T>) | Initializes a new instance of the ValueList<T> struct with the specified immutable array. |
| ValueList(params ReadOnlySpan<T>) | Initializes a new instance of the ValueList<T> struct by copying the specified span. |
Properties
| Name | Description |
|---|---|
| Count | Gets the number of elements in the collection. |
| this[int] | Gets the element at the specified index in the read-only list. |
| Value | Gets the immutable items. |
Methods
| Name | Description |
|---|---|
| AsMemory() | Returns the items as a ReadOnlyMemory<T>. |
| AsSpan() | Returns the items as a ReadOnlySpan<T>. |
| Equals(ValueList<T>) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Indicates whether this instance and a specified object are equal. |
| GetEnumerator() | Returns an enumerator that iterates through the collection. |
| GetHashCode() | Returns the hash code for this instance. |
| Parse(string) | Parses a string into a ValueList<T>. |
| ToArray() | Returns a copy of the items as a new array. |
| ToString() | Returns the encoded string representation of the items. |
| TryParse(string?, out ValueList<T>) | Tries to parse a string into a ValueList<T>. |
Operators
| Name | Description |
|---|---|
| operator ==(ValueList<T>, ValueList<T>) | Determines whether two ValueList<T> instances are equal. |
| implicit operator ImmutableArray<T>(ValueList<T>) | Converts a ValueList<T> to an ImmutableArray<T> without copying. |
| implicit operator ReadOnlyMemory<T>(ValueList<T>) | Converts a ValueList<T> to a ReadOnlyMemory<T> without copying. |
| implicit operator ReadOnlySpan<T>(ValueList<T>) | Converts a ValueList<T> to a ReadOnlySpan<T> without copying. |
| implicit operator ValueList<T>(ImmutableArray<T>) | Converts an ImmutableArray<T> to a ValueList<T> without copying. |
| operator !=(ValueList<T>, ValueList<T>) | Determines whether two ValueList<T> instances are not equal. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IEnumerable.GetEnumerator() | Returns an enumerator that iterates through a collection. |
| IParsable<ValueList<T>>.Parse(string, IFormatProvider?) | Parses a string into a value. |
| IParsable<ValueList<T>>.TryParse(string?, IFormatProvider?, out ValueList<T>) | Tries to parse a string into a value. |