Struct MessagePackValue
- Namespace
- Nerdbank.MessagePack
- Assembly
- Nerdbank.MessagePack.dll
A variant type that can represent any of the MessagePack primitives.
[GenerateShape]
public readonly struct MessagePackValue : IEquatable<MessagePackValue>, IShapeable<MessagePackValue>
- Implements
- Inherited Members
Constructors
MessagePackValue(Extension)
Initializes a new instance of the MessagePackValue struct with an Extension.
public MessagePackValue(Extension value)
Parameters
value
ExtensionThe extension to initialize with.
MessagePackValue(MessagePackValue[])
Initializes a new instance of the MessagePackValue struct with an array.
public MessagePackValue(MessagePackValue[] value)
Parameters
value
MessagePackValue[]The array to initialize with.
MessagePackValue(bool)
Initializes a new instance of the MessagePackValue struct with a bool value.
public MessagePackValue(bool value)
Parameters
MessagePackValue(byte)
Initializes a new instance of the MessagePackValue struct with a byte value.
public MessagePackValue(byte value)
Parameters
MessagePackValue(byte[])
Initializes a new instance of the MessagePackValue struct with binary data.
public MessagePackValue(byte[] value)
Parameters
value
byte[]The data to initialize with.
MessagePackValue(IReadOnlyDictionary<MessagePackValue, MessagePackValue>)
Initializes a new instance of the MessagePackValue struct with a map.
public MessagePackValue(IReadOnlyDictionary<MessagePackValue, MessagePackValue> value)
Parameters
value
IReadOnlyDictionary<MessagePackValue, MessagePackValue>The map to initialize with.
MessagePackValue(DateTime)
Initializes a new instance of the MessagePackValue struct with an DateTime.
public MessagePackValue(DateTime value)
Parameters
value
DateTimeThe value to initialize with.
MessagePackValue(double)
Initializes a new instance of the MessagePackValue struct with a double value.
public MessagePackValue(double value)
Parameters
MessagePackValue(short)
Initializes a new instance of the MessagePackValue struct with a short value.
public MessagePackValue(short value)
Parameters
MessagePackValue(int)
Initializes a new instance of the MessagePackValue struct with an int value.
public MessagePackValue(int value)
Parameters
MessagePackValue(long)
Initializes a new instance of the MessagePackValue struct with a long value.
public MessagePackValue(long value)
Parameters
MessagePackValue(sbyte)
Initializes a new instance of the MessagePackValue struct with an sbyte value.
public MessagePackValue(sbyte value)
Parameters
MessagePackValue(float)
Initializes a new instance of the MessagePackValue struct with a float value.
public MessagePackValue(float value)
Parameters
MessagePackValue(string?)
Initializes a new instance of the MessagePackValue struct with a string or null value.
public MessagePackValue(string? value)
Parameters
MessagePackValue(ushort)
Initializes a new instance of the MessagePackValue struct with an ushort value.
public MessagePackValue(ushort value)
Parameters
MessagePackValue(uint)
Initializes a new instance of the MessagePackValue struct with a uint value.
public MessagePackValue(uint value)
Parameters
MessagePackValue(ulong)
Initializes a new instance of the MessagePackValue struct with a ulong value.
public MessagePackValue(ulong value)
Parameters
Fields
Nil
A token that represents Nil.
public static readonly MessagePackValue Nil
Field Value
Properties
Kind
Gets the type of the MessagePack token.
public MessagePackValueKind Kind { get; }
Property Value
ValueAsArray
Gets the value as an array.
public ReadOnlyMemory<MessagePackValue> ValueAsArray { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an array.
ValueAsBinary
Gets the value as a ReadOnlyMemory<T> of byte.
public ReadOnlyMemory<byte> ValueAsBinary { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not binary data.
ValueAsBoolean
Gets the value as a bool.
public bool ValueAsBoolean { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not a bool.
ValueAsByte
Gets the value as a byte.
public byte ValueAsByte { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsDateTime
Gets the value as an DateTime.
public DateTime ValueAsDateTime { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an DateTime.
ValueAsDouble
Gets the value as a double.
public double ValueAsDouble { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not a floating point number.
ValueAsExtension
Gets the value as an Extension.
public Extension ValueAsExtension { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an Extension.
ValueAsInt16
Gets the value as a short.
public short ValueAsInt16 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsInt32
Gets the value as an int.
public int ValueAsInt32 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsInt64
Gets the value as a long.
public long ValueAsInt64 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsMap
Gets the value as an map.
public IReadOnlyDictionary<MessagePackValue, MessagePackValue> ValueAsMap { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an map or a null.
ValueAsSByte
Gets the value as an sbyte.
public sbyte ValueAsSByte { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsSingle
Gets the value as a float.
public float ValueAsSingle { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not a floating point number.
ValueAsString
Gets the value as a string.
public string? ValueAsString { get; }
Property Value
Exceptions
ValueAsUInt16
Gets the value as an ushort.
public ushort ValueAsUInt16 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsUInt32
Gets the value as a uint.
public uint ValueAsUInt32 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
ValueAsUInt64
Gets the value as a ulong.
public ulong ValueAsUInt64 { get; }
Property Value
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
Methods
Equals(MessagePackValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(MessagePackValue other)
Parameters
other
MessagePackValueAn object to compare with this object.
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
explicit operator Extension(MessagePackValue)
Explicitly converts a MessagePackValue to an Extension.
public static explicit operator Extension(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
explicit operator bool(MessagePackValue)
Explicitly converts a MessagePackValue to a bool.
public static explicit operator bool(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not a bool.
explicit operator byte(MessagePackValue)
Explicitly converts a MessagePackValue to a byte.
public static explicit operator byte(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an unsigned integer.
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator FrozenDictionary<MessagePackValue, MessagePackValue>(MessagePackValue)
Explicitly converts a MessagePackValue to a FrozenDictionary<TKey, TValue>.
public static explicit operator FrozenDictionary<MessagePackValue, MessagePackValue>(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an map or a null.
explicit operator Dictionary<MessagePackValue, MessagePackValue>(MessagePackValue)
Explicitly converts a MessagePackValue to a Dictionary<TKey, TValue>.
public static explicit operator Dictionary<MessagePackValue, MessagePackValue>(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an map or a null.
explicit operator DateTime(MessagePackValue)
Explicitly converts a MessagePackValue to an DateTime.
public static explicit operator DateTime(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
explicit operator double(MessagePackValue)
Explicitly converts a MessagePackValue to a double.
public static explicit operator double(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not a floating point number.
explicit operator short(MessagePackValue)
Explicitly converts a MessagePackValue to a short.
public static explicit operator short(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator int(MessagePackValue)
Explicitly converts a MessagePackValue to an int.
public static explicit operator int(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator long(MessagePackValue)
Explicitly converts a MessagePackValue to a long.
public static explicit operator long(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator ReadOnlyMemory<MessagePackValue>(MessagePackValue)
Explicitly converts a MessagePackValue to an array.
public static explicit operator ReadOnlyMemory<MessagePackValue>(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an array.
explicit operator ReadOnlyMemory<byte>(MessagePackValue)
Explicitly converts a MessagePackValue to a nullable string.
public static explicit operator ReadOnlyMemory<byte>(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
explicit operator sbyte(MessagePackValue)
Explicitly converts a MessagePackValue to an sbyte.
public static explicit operator sbyte(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator float(MessagePackValue)
Explicitly converts a MessagePackValue to a float.
public static explicit operator float(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not a floating point number.
explicit operator string?(MessagePackValue)
Explicitly converts a MessagePackValue to a nullable string.
public static explicit operator string?(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
explicit operator ushort(MessagePackValue)
Explicitly converts a MessagePackValue to a ushort.
public static explicit operator ushort(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator uint(MessagePackValue)
Explicitly converts a MessagePackValue to a uint.
public static explicit operator uint(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
explicit operator ulong(MessagePackValue)
Explicitly converts a MessagePackValue to a ulong.
public static explicit operator ulong(MessagePackValue token)
Parameters
token
MessagePackValueThe MessagePackValue to convert.
Returns
Exceptions
- InvalidCastException
Thrown when the value is not an integer.
- OverflowException
Thrown when the value cannot be represented in an integer of the required length.
implicit operator MessagePackValue(Extension)
Implicitly converts an Extension to a MessagePackValue.
public static implicit operator MessagePackValue(Extension value)
Parameters
Returns
implicit operator MessagePackValue(MessagePackValue[])
Implicitly converts an array to a MessagePackValue.
public static implicit operator MessagePackValue(MessagePackValue[] value)
Parameters
value
MessagePackValue[]The array to convert.
Returns
implicit operator MessagePackValue(bool)
Implicitly converts a bool to a MessagePackValue.
public static implicit operator MessagePackValue(bool value)
Parameters
value
boolThe boolean value to convert.
Returns
implicit operator MessagePackValue(byte)
Implicitly converts a byte to a MessagePackValue.
public static implicit operator MessagePackValue(byte value)
Parameters
Returns
implicit operator MessagePackValue(byte[]?)
Implicitly converts binary data to a MessagePackValue.
public static implicit operator MessagePackValue(byte[]? value)
Parameters
value
byte[]The binary data value to convert.
Returns
implicit operator MessagePackValue(FrozenDictionary<MessagePackValue, MessagePackValue>)
Implicitly converts a FrozenDictionary<TKey, TValue> to a MessagePackValue.
public static implicit operator MessagePackValue(FrozenDictionary<MessagePackValue, MessagePackValue> value)
Parameters
value
FrozenDictionary<MessagePackValue, MessagePackValue>The map to convert.
Returns
implicit operator MessagePackValue(Dictionary<MessagePackValue, MessagePackValue>)
Implicitly converts a Dictionary<TKey, TValue> to a MessagePackValue.
public static implicit operator MessagePackValue(Dictionary<MessagePackValue, MessagePackValue> value)
Parameters
value
Dictionary<MessagePackValue, MessagePackValue>The map to convert.
Returns
implicit operator MessagePackValue(DateTime)
Implicitly converts an DateTime to a MessagePackValue.
public static implicit operator MessagePackValue(DateTime value)
Parameters
Returns
implicit operator MessagePackValue(double)
Implicitly converts a double to a MessagePackValue.
public static implicit operator MessagePackValue(double value)
Parameters
Returns
implicit operator MessagePackValue(short)
Implicitly converts a short to a MessagePackValue.
public static implicit operator MessagePackValue(short value)
Parameters
Returns
implicit operator MessagePackValue(int)
Implicitly converts an int to a MessagePackValue.
public static implicit operator MessagePackValue(int value)
Parameters
Returns
implicit operator MessagePackValue(long)
Implicitly converts a long to a MessagePackValue.
public static implicit operator MessagePackValue(long value)
Parameters
Returns
implicit operator MessagePackValue(sbyte)
Implicitly converts an sbyte to a MessagePackValue.
public static implicit operator MessagePackValue(sbyte value)
Parameters
Returns
implicit operator MessagePackValue(float)
Implicitly converts a float to a MessagePackValue.
public static implicit operator MessagePackValue(float value)
Parameters
Returns
implicit operator MessagePackValue(string?)
Implicitly converts a nullable string to a MessagePackValue.
public static implicit operator MessagePackValue(string? value)
Parameters
Returns
implicit operator MessagePackValue(ushort)
Implicitly converts a ushort to a MessagePackValue.
public static implicit operator MessagePackValue(ushort value)
Parameters
Returns
implicit operator MessagePackValue(uint)
Implicitly converts a uint to a MessagePackValue.
public static implicit operator MessagePackValue(uint value)
Parameters
Returns
implicit operator MessagePackValue(ulong)
Implicitly converts a ulong to a MessagePackValue.
public static implicit operator MessagePackValue(ulong value)