Udostępnij za pośrednictwem


CborWriter.WriteStartMap(Nullable<Int32>) Method

Definition

Writes the start of a definite or indefinite-length map (major type 5).

public:
 void WriteStartMap(Nullable<int> definiteLength);
public void WriteStartMap (int? definiteLength);
member this.WriteStartMap : Nullable<int> -> unit
Public Sub WriteStartMap (definiteLength As Nullable(Of Integer))

Parameters

definiteLength
Nullable<Int32>

The length of the definite-length map, or null for an indefinite-length map.

Exceptions

The definiteLength parameter cannot be negative.

Writing a new value exceeds the definite length of the parent data item.

-or-

The major type of the encoded value is not permitted in the parent data item.

-or-

The written data is not accepted under the current conformance mode.

Remarks

In canonical conformance modes, the writer will reject indefinite-length writes unless the ConvertIndefiniteLengthEncodings flag is enabled. Map contents are written as if arrays twice the length of the map's declared size. For example, a map of size 1 containing a key of type Int32 with a value of type string must be written by successive calls to WriteInt32(Int32) and WriteTextString(ReadOnlySpan<Char>). It is up to the caller to keep track of whether the next call is a key or a value. Fundamentally, this is a technical restriction stemming from the fact that CBOR allows keys of any type, for example, a map can contain keys that are maps themselves.

Applies to