Show / Hide Table of Contents

    Class InstanceIdentifier

    The identifier used to distinguish the instances of the same type. Used mostly for logging and debugging.

    Inheritance
    object
    InstanceIdentifier
    Implements
    IEquatable<InstanceIdentifier>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Silverback
    Assembly: Silverback.Core.dll
    Syntax
    public sealed class InstanceIdentifier : IEquatable<InstanceIdentifier>
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    Constructors

    | Improve this doc View source

    InstanceIdentifier(Guid?)

    Initializes a new instance of the InstanceIdentifier class.

    Declaration
    public InstanceIdentifier(Guid? value = null)
    Parameters
    Type Name Description
    Guid? value

    The Guid representing the identifier value. If null a random one will be generated.

    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    Properties

    | Improve this doc View source

    Value

    Gets the identifier.

    Declaration
    public string Value { get; }
    Property Value
    Type Description
    string
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    Methods

    | Improve this doc View source

    Equals(InstanceIdentifier?)

    Indicates whether the current object is equal to another object of the same type.

    Declaration
    public bool Equals(InstanceIdentifier? other)
    Parameters
    Type Name Description
    InstanceIdentifier other

    An object to compare with this object.

    Returns
    Type Description
    bool

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

    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    | Improve this doc View source

    Equals(object?)

    Determines whether the specified object is equal to the current object.

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

    The object to compare with the current object.

    Returns
    Type Description
    bool

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

    Overrides
    object.Equals(object)
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    | Improve this doc View source

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    object.GetHashCode()
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    | Improve this doc View source

    ToString()

    Converts the InstanceIdentifier to a string.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The identifier value.

    Overrides
    object.ToString()
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    Operators

    | Improve this doc View source

    operator ==(InstanceIdentifier?, InstanceIdentifier?)

    The identifier used to distinguish the instances of the same type. Used mostly for logging and debugging.

    Declaration
    public static bool operator ==(InstanceIdentifier? left, InstanceIdentifier? right)
    Parameters
    Type Name Description
    InstanceIdentifier left
    InstanceIdentifier right
    Returns
    Type Description
    bool
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    | Improve this doc View source

    implicit operator string(InstanceIdentifier?)

    Converts the InstanceIdentifier to a string.

    Declaration
    public static implicit operator string(InstanceIdentifier? identifier)
    Parameters
    Type Name Description
    InstanceIdentifier identifier

    The InstanceIdentifier to be converted.

    Returns
    Type Description
    string

    The identifier value.

    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    | Improve this doc View source

    operator !=(InstanceIdentifier?, InstanceIdentifier?)

    The identifier used to distinguish the instances of the same type. Used mostly for logging and debugging.

    Declaration
    public static bool operator !=(InstanceIdentifier? left, InstanceIdentifier? right)
    Parameters
    Type Name Description
    InstanceIdentifier left
    InstanceIdentifier right
    Returns
    Type Description
    bool
    Remarks

    Using this class instead of a Guid allocates more memory (about 152 bytes, instead of the 16 bytes used by a Guid) because the value is stored directly as string to avoid extra allocations in the ToString() method (e.g. when writing to a log).

    This is also a reference type and passing is around requires less allocations.

    Implements

    IEquatable<T>
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini