Table of Contents

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 Extension

The 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

value bool

The bool value to initialize with.

MessagePackValue(byte)

Initializes a new instance of the MessagePackValue struct with a byte value.

public MessagePackValue(byte value)

Parameters

value byte

The byte value to initialize with.

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 DateTime

The value to initialize with.

MessagePackValue(double)

Initializes a new instance of the MessagePackValue struct with a double value.

public MessagePackValue(double value)

Parameters

value double

The double value to initialize with.

MessagePackValue(short)

Initializes a new instance of the MessagePackValue struct with a short value.

public MessagePackValue(short value)

Parameters

value short

The short value to initialize with.

MessagePackValue(int)

Initializes a new instance of the MessagePackValue struct with an int value.

public MessagePackValue(int value)

Parameters

value int

The int value to initialize with.

MessagePackValue(long)

Initializes a new instance of the MessagePackValue struct with a long value.

public MessagePackValue(long value)

Parameters

value long

The long value to initialize with.

MessagePackValue(sbyte)

Initializes a new instance of the MessagePackValue struct with an sbyte value.

public MessagePackValue(sbyte value)

Parameters

value sbyte

The sbyte value to initialize with.

MessagePackValue(float)

Initializes a new instance of the MessagePackValue struct with a float value.

public MessagePackValue(float value)

Parameters

value float

The float value to initialize with.

MessagePackValue(string?)

Initializes a new instance of the MessagePackValue struct with a string or null value.

public MessagePackValue(string? value)

Parameters

value string

The string value to initialize with.

MessagePackValue(ushort)

Initializes a new instance of the MessagePackValue struct with an ushort value.

public MessagePackValue(ushort value)

Parameters

value ushort

The ushort value to initialize with.

MessagePackValue(uint)

Initializes a new instance of the MessagePackValue struct with a uint value.

public MessagePackValue(uint value)

Parameters

value uint

The uint value to initialize with.

MessagePackValue(ulong)

Initializes a new instance of the MessagePackValue struct with a ulong value.

public MessagePackValue(ulong value)

Parameters

value ulong

The ulong value to initialize with.

Fields

Nil

A token that represents Nil.

public static readonly MessagePackValue Nil

Field Value

MessagePackValue

Properties

Kind

Gets the type of the MessagePack token.

public MessagePackValueKind Kind { get; }

Property Value

MessagePackValueKind

ValueAsArray

Gets the value as an array.

public ReadOnlyMemory<MessagePackValue> ValueAsArray { get; }

Property Value

ReadOnlyMemory<MessagePackValue>

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

ReadOnlyMemory<byte>

Exceptions

InvalidCastException

Thrown when the value is not binary data.

ValueAsBoolean

Gets the value as a bool.

public bool ValueAsBoolean { get; }

Property Value

bool

Exceptions

InvalidCastException

Thrown when the value is not a bool.

ValueAsByte

Gets the value as a byte.

public byte ValueAsByte { get; }

Property Value

byte

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

DateTime

Exceptions

InvalidCastException

Thrown when the value is not an DateTime.

ValueAsDouble

Gets the value as a double.

public double ValueAsDouble { get; }

Property Value

double

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

Extension

Exceptions

InvalidCastException

Thrown when the value is not an Extension.

ValueAsInt16

Gets the value as a short.

public short ValueAsInt16 { get; }

Property Value

short

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

int

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

long

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

IReadOnlyDictionary<MessagePackValue, MessagePackValue>

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

sbyte

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

float

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

string

Exceptions

InvalidCastException

Thrown when the value is not a string or a null.

ValueAsUInt16

Gets the value as an ushort.

public ushort ValueAsUInt16 { get; }

Property Value

ushort

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

uint

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

ulong

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 MessagePackValue

An object to compare with this object.

Returns

bool

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

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 MessagePackValue

The MessagePackValue to convert.

Returns

Extension

explicit operator bool(MessagePackValue)

Explicitly converts a MessagePackValue to a bool.

public static explicit operator bool(MessagePackValue token)

Parameters

token MessagePackValue

The MessagePackValue to convert.

Returns

bool

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 MessagePackValue

The MessagePackValue to convert.

Returns

byte

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)

public static explicit operator FrozenDictionary<MessagePackValue, MessagePackValue>(MessagePackValue token)

Parameters

token MessagePackValue

The MessagePackValue to convert.

Returns

FrozenDictionary<MessagePackValue, MessagePackValue>

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 MessagePackValue

The MessagePackValue to convert.

Returns

Dictionary<MessagePackValue, MessagePackValue>

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 MessagePackValue

The MessagePackValue to convert.

Returns

DateTime

explicit operator double(MessagePackValue)

Explicitly converts a MessagePackValue to a double.

public static explicit operator double(MessagePackValue token)

Parameters

token MessagePackValue

The MessagePackValue to convert.

Returns

double

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 MessagePackValue

The MessagePackValue to convert.

Returns

short

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 MessagePackValue

The MessagePackValue to convert.

Returns

int

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 MessagePackValue

The MessagePackValue to convert.

Returns

long

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 MessagePackValue

The MessagePackValue to convert.

Returns

ReadOnlyMemory<MessagePackValue>

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 MessagePackValue

The MessagePackValue to convert.

Returns

ReadOnlyMemory<byte>

Exceptions

InvalidCastException

Thrown when the value is not a string or a null.

explicit operator sbyte(MessagePackValue)

Explicitly converts a MessagePackValue to an sbyte.

public static explicit operator sbyte(MessagePackValue token)

Parameters

token MessagePackValue

The MessagePackValue to convert.

Returns

sbyte

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 MessagePackValue

The MessagePackValue to convert.

Returns

float

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 MessagePackValue

The MessagePackValue to convert.

Returns

string

Exceptions

InvalidCastException

Thrown when the value is not a string or a null.

explicit operator ushort(MessagePackValue)

Explicitly converts a MessagePackValue to a ushort.

public static explicit operator ushort(MessagePackValue token)

Parameters

token MessagePackValue

The MessagePackValue to convert.

Returns

ushort

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 MessagePackValue

The MessagePackValue to convert.

Returns

uint

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 MessagePackValue

The MessagePackValue to convert.

Returns

ulong

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

value Extension

The Extension to convert.

Returns

MessagePackValue

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

MessagePackValue

implicit operator MessagePackValue(bool)

Implicitly converts a bool to a MessagePackValue.

public static implicit operator MessagePackValue(bool value)

Parameters

value bool

The boolean value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(byte)

Implicitly converts a byte to a MessagePackValue.

public static implicit operator MessagePackValue(byte value)

Parameters

value byte

The byte value to convert.

Returns

MessagePackValue

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

MessagePackValue

implicit operator MessagePackValue(FrozenDictionary<MessagePackValue, MessagePackValue>)

public static implicit operator MessagePackValue(FrozenDictionary<MessagePackValue, MessagePackValue> value)

Parameters

value FrozenDictionary<MessagePackValue, MessagePackValue>

The map to convert.

Returns

MessagePackValue

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

MessagePackValue

implicit operator MessagePackValue(DateTime)

Implicitly converts an DateTime to a MessagePackValue.

public static implicit operator MessagePackValue(DateTime value)

Parameters

value DateTime

The DateTime to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(double)

Implicitly converts a double to a MessagePackValue.

public static implicit operator MessagePackValue(double value)

Parameters

value double

The double value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(short)

Implicitly converts a short to a MessagePackValue.

public static implicit operator MessagePackValue(short value)

Parameters

value short

The short value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(int)

Implicitly converts an int to a MessagePackValue.

public static implicit operator MessagePackValue(int value)

Parameters

value int

The int value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(long)

Implicitly converts a long to a MessagePackValue.

public static implicit operator MessagePackValue(long value)

Parameters

value long

The long value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(sbyte)

Implicitly converts an sbyte to a MessagePackValue.

public static implicit operator MessagePackValue(sbyte value)

Parameters

value sbyte

The sbyte value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(float)

Implicitly converts a float to a MessagePackValue.

public static implicit operator MessagePackValue(float value)

Parameters

value float

The float value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(string?)

Implicitly converts a nullable string to a MessagePackValue.

public static implicit operator MessagePackValue(string? value)

Parameters

value string

The nullable string value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(ushort)

Implicitly converts a ushort to a MessagePackValue.

public static implicit operator MessagePackValue(ushort value)

Parameters

value ushort

The ushort value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(uint)

Implicitly converts a uint to a MessagePackValue.

public static implicit operator MessagePackValue(uint value)

Parameters

value uint

The uint value to convert.

Returns

MessagePackValue

implicit operator MessagePackValue(ulong)

Implicitly converts a ulong to a MessagePackValue.

public static implicit operator MessagePackValue(ulong value)

Parameters

value ulong

The ulong value to convert.

Returns

MessagePackValue