Table of Contents

Struct ArrayConverter<T, TConverter>

Namespace
DynaSharp.Serialization
Assembly
DynaSharp.dll

Converts T[] to and from a list value (L), each element in the form of TConverter.

public readonly struct ArrayConverter<T, TConverter> : IDynamoDbConverter<T[]> where TConverter : IDynamoDbConverter<T>

Type Parameters

T

The element type.

TConverter

The converter of the elements.

Implements
Inherited Members

Remarks

The elements of a DynamoDB list may have different types; this converter reads them all with TConverter, so an element of another type fails the read. An empty list is valid, and reads as an empty array. To store an array as a set instead, see SetArrayConverter<T, TElement>. Infrastructure: compatible only within a package version, because generated code comes from the generator of the same package.

Explicit Interface Implementations

Read(ref DynamoDbReader, AttributeType)

Reads the attribute value the reader is positioned on.

static T[] Read(ref DynamoDbReader reader, AttributeType type)

Parameters

reader DynamoDbReader

The reader, positioned on the value after ReadStartAttribute() or TryReadStartAttribute(out AttributeType). The caller reads the closing brace afterwards, so the converter must read the value completely (all elements of a list, map or set) and nothing more.

type AttributeType

The DynamoDB type of the value. Check it with Expect(AttributeType, AttributeType), which throws JsonException for types the converter does not support. Null is passed to the converter too, so it can map it to null where that makes sense.

Returns

T[]

The value.

Exceptions

JsonException

type is not List, or an element fails to read.

Write(DynamoDbWriter, T[])

Writes a value as one complete attribute value, for example with WriteNumber<T>(T).

static void Write(DynamoDbWriter writer, T[] value)

Parameters

writer DynamoDbWriter

The writer, positioned where a value is expected (after an attribute name, or inside a list). It is a ref struct, so it is never null and needs no check.

value T[]

The value.

Exceptions

ArgumentNullException

value is null.