Search Results for

    Show / Hide Table of Contents

    Struct Link<TLinkAddress>

    Represents a link in the Links Notation with an optional identifier and nested values. Links can represent simple references, complex nested structures, or relationships between references to links.

    Implements
    IEquatable<Link<TLinkAddress>>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Link.Foundation.Links.Notation
    Assembly: Link.Foundation.Links.Notation.dll
    Syntax
    public struct Link<TLinkAddress> : IEquatable<Link<TLinkAddress>>
    Type Parameters
    Name Description
    TLinkAddress

    The type used for link addresses/identifiers. This can be any type that uniquely identifies a link, such as string, int, or Guid.

    Constructors

    | Edit this page View Source

    Link(params Link<TLinkAddress>[])

    Initializes a new anonymous link with the specified array of values.

    Declaration
    public Link(params Link<TLinkAddress>[] values)
    Parameters
    Type Name Description
    Link<TLinkAddress>[] values

    The nested link values as a parameter array.

    | Edit this page View Source

    Link(IList<Link<TLinkAddress>>)

    Initializes a new anonymous link with the specified values.

    Declaration
    public Link(IList<Link<TLinkAddress>> values)
    Parameters
    Type Name Description
    IList<Link<TLinkAddress>> values

    The nested link values.

    | Edit this page View Source

    Link(TLinkAddress)

    Initializes a new simple reference link with the specified identifier.

    Declaration
    public Link(TLinkAddress id)
    Parameters
    Type Name Description
    TLinkAddress id

    The link identifier or address.

    | Edit this page View Source

    Link(TLinkAddress?, IList<Link<TLinkAddress>>?)

    Initializes a new link with the specified identifier and values.

    Declaration
    public Link(TLinkAddress? id, IList<Link<TLinkAddress>>? values)
    Parameters
    Type Name Description
    TLinkAddress id

    The link identifier or address.

    IList<Link<TLinkAddress>> values

    The nested link values.

    Fields

    | Edit this page View Source

    Id

    Gets the identifier or address of this link. Can be null for anonymous links.

    Declaration
    public readonly TLinkAddress? Id
    Field Value
    Type Description
    TLinkAddress
    | Edit this page View Source

    Values

    Gets the collection of nested link values. Can be null or empty for simple reference links.

    Declaration
    public readonly IList<Link<TLinkAddress>>? Values
    Field Value
    Type Description
    IList<Link<TLinkAddress>>

    Methods

    | Edit this page View Source

    Combine(Link<TLinkAddress>)

    Combines this link with another link to create a new link containing both as values.

    Declaration
    public Link<TLinkAddress> Combine(Link<TLinkAddress> other)
    Parameters
    Type Name Description
    Link<TLinkAddress> other

    The other link to combine with.

    Returns
    Type Description
    Link<TLinkAddress>

    A new link containing both links as values.

    | Edit this page View Source

    Equals(Link<TLinkAddress>)

    Indicates whether the current link is equal to another link. Two anonymous links (both with null Ids) are considered equal if their values are equal.

    Declaration
    public bool Equals(Link<TLinkAddress> other)
    Parameters
    Type Name Description
    Link<TLinkAddress> other

    The link to compare with this link.

    Returns
    Type Description
    bool

    True if the current link is equal to the other parameter; otherwise, false.

    | Edit this page View Source

    Equals(object?)

    Determines whether the specified object is equal to this link.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with this link.

    Returns
    Type Description
    bool

    True if the specified object is equal to this link; otherwise, false.

    Overrides
    ValueType.Equals(object)
    | Edit this page View Source

    EscapeReference(string?)

    Escapes a reference string for safe use in Links Notation format by adding quotes if necessary.

    Declaration
    public static string EscapeReference(string? reference)
    Parameters
    Type Name Description
    string reference

    The reference string to escape.

    Returns
    Type Description
    string

    The escaped reference string with appropriate quoting.

    | Edit this page View Source

    GetHashCode()

    Returns the hash code for this link.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for this link.

    Overrides
    ValueType.GetHashCode()
    | Edit this page View Source

    GetValueString(Link<TLinkAddress>)

    Gets the string representation of a link value, choosing the appropriate format.

    Declaration
    public static string GetValueString(Link<TLinkAddress> value)
    Parameters
    Type Name Description
    Link<TLinkAddress> value

    The link value to convert to string.

    Returns
    Type Description
    string

    The string representation of the link value.

    | Edit this page View Source

    GetValuesString()

    Gets the string representation of the link's values.

    Declaration
    public string GetValuesString()
    Returns
    Type Description
    string

    A space-separated string of the values, or empty string if no values exist.

    | Edit this page View Source

    Simplify()

    Simplifies the link structure by unwrapping single-value containers and recursively simplifying nested values.

    Declaration
    public Link<TLinkAddress> Simplify()
    Returns
    Type Description
    Link<TLinkAddress>

    A simplified version of this link.

    | Edit this page View Source

    ToLinkOrIdString()

    Converts the link to its string representation, choosing between simple reference format or full link format.

    Declaration
    public string ToLinkOrIdString()
    Returns
    Type Description
    string

    A string representation optimized for the link's content.

    | Edit this page View Source

    ToString()

    Returns the string representation of this link in Links Notation format.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string representation of the link with proper escaping and formatting.

    Overrides
    ValueType.ToString()

    Operators

    | Edit this page View Source

    operator ==(Link<TLinkAddress>, Link<TLinkAddress>)

    Determines whether two link instances are equal.

    Declaration
    public static bool operator ==(Link<TLinkAddress> left, Link<TLinkAddress> right)
    Parameters
    Type Name Description
    Link<TLinkAddress> left

    The first link to compare.

    Link<TLinkAddress> right

    The second link to compare.

    Returns
    Type Description
    bool

    True if the links are equal; otherwise, false.

    | Edit this page View Source

    implicit operator Link<TLinkAddress>((Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target))

    Implicitly converts a source-linker-target triplet to an anonymous link.

    Declaration
    public static implicit operator Link<TLinkAddress>((Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target) value)
    Parameters
    Type Name Description
    (Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target) value

    The tuple containing source, linker, and target links.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    implicit operator Link<TLinkAddress>((Link<TLinkAddress> source, Link<TLinkAddress> target))

    Implicitly converts a source-target pair to an anonymous link.

    Declaration
    public static implicit operator Link<TLinkAddress>((Link<TLinkAddress> source, Link<TLinkAddress> target) value)
    Parameters
    Type Name Description
    (Link<TLinkAddress> source, Link<TLinkAddress> target) value

    The tuple containing source and target links.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    implicit operator Link<TLinkAddress>((id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target))

    Implicitly converts a tuple of identifier, source, linker, and target to a link.

    Declaration
    public static implicit operator Link<TLinkAddress>((id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target) value)
    Parameters
    Type Name Description
    (id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> linker, Link<TLinkAddress> target) value

    The tuple containing id, source, linker, and target.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    implicit operator Link<TLinkAddress>((id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> target))

    Implicitly converts a tuple of identifier, source, and target to a link.

    Declaration
    public static implicit operator Link<TLinkAddress>((id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> target) value)
    Parameters
    Type Name Description
    (id<TLinkAddress> id, Link<TLinkAddress> source, Link<TLinkAddress> target) value

    The tuple containing id, source and target.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    implicit operator Link<TLinkAddress>((TLinkAddress, IList<Link<TLinkAddress>>))

    Implicitly converts a tuple of identifier and values to a link.

    Declaration
    public static implicit operator Link<TLinkAddress>((TLinkAddress, IList<Link<TLinkAddress>>) value)
    Parameters
    Type Name Description
    (TLinkAddress, IList<Link<TLinkAddress>>) value

    The tuple containing identifier and values.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    implicit operator Link<TLinkAddress>(TLinkAddress)

    Implicitly converts a value to a simple reference link.

    Declaration
    public static implicit operator Link<TLinkAddress>(TLinkAddress value)
    Parameters
    Type Name Description
    TLinkAddress value

    The value to convert.

    Returns
    Type Description
    Link<TLinkAddress>
    | Edit this page View Source

    operator !=(Link<TLinkAddress>, Link<TLinkAddress>)

    Determines whether two link instances are not equal.

    Declaration
    public static bool operator !=(Link<TLinkAddress> left, Link<TLinkAddress> right)
    Parameters
    Type Name Description
    Link<TLinkAddress> left

    The first link to compare.

    Link<TLinkAddress> right

    The second link to compare.

    Returns
    Type Description
    bool

    True if the links are not equal; otherwise, false.

    Implements

    IEquatable<T>

    Extension Methods

    LinkFormatExtensions.FormatWithOptions<TLinkAddress>(Link<TLinkAddress>, FormatOptions)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX