Class InstanceIdentifier
The identifier used to distinguish the instances of the same type. Used mostly for logging and debugging.
Implements
Inherited Members
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 sourceInstanceIdentifier(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 |
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 sourceValue
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 sourceEquals(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 |
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.
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
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.
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
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.
ToString()
Converts the InstanceIdentifier to a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The identifier value. |
Overrides
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 sourceoperator ==(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.
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.
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.