Struct DerivedTypeIdentifier
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
Identifies a derived type using a string or integer alias.
public struct DerivedTypeIdentifier : IEquatable<DerivedTypeIdentifier>
- Implements
- Inherited Members
Constructors
DerivedTypeIdentifier(int)
Initializes a new instance of the DerivedTypeIdentifier struct.
public DerivedTypeIdentifier(int alias)
Parameters
aliasintThe integer alias.
DerivedTypeIdentifier(string)
Initializes a new instance of the DerivedTypeIdentifier struct.
public DerivedTypeIdentifier(string alias)
Parameters
aliasstringThe string alias.
Properties
IntAlias
Gets the integer alias.
public int IntAlias { get; }
Property Value
Exceptions
- InvalidOperationException
The identifier is not an integer.
StringAlias
Gets the string alias.
public string StringAlias { get; }
Property Value
Exceptions
- InvalidOperationException
The identifier is not a string.
Type
Gets the alias kind.
public DerivedTypeIdentifier.AliasType Type { get; }
Property Value
Utf8Alias
Gets the UTF-8 encoding of the string alias.
public ReadOnlyMemory<byte> Utf8Alias { get; }
Property Value
Exceptions
- InvalidOperationException
The identifier is not a string.
Methods
Equals(DerivedTypeIdentifier)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(DerivedTypeIdentifier other)
Parameters
otherDerivedTypeIdentifierAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
implicit operator DerivedTypeIdentifier(int)
Converts an integer to an identifier.
public static implicit operator DerivedTypeIdentifier(int alias)
Parameters
aliasintThe alias.
Returns
implicit operator DerivedTypeIdentifier(string)
Converts a string to an identifier.
public static implicit operator DerivedTypeIdentifier(string alias)
Parameters
aliasstringThe alias.