Struct ReadOnlyListConverter<T, TConverter>
- Namespace
- DynaSharp.Serialization
- Assembly
- DynaSharp.dll
Converts IReadOnlyList<T> to and from a list value (L), each element in the form of TConverter.
public readonly struct ReadOnlyListConverter<T, TConverter> : IDynamoDbConverter<IReadOnlyList<T>> where TConverter : IDynamoDbConverter<T>
Type Parameters
TThe element type.
TConverterThe converter of the elements.
- Implements
- Inherited Members
Remarks
See ArrayConverter<T, TConverter> for what a list may hold. A list that is read is an array of exactly its length, the cheapest read-only list; code that casts it back to an array can change it. Infrastructure: compatible only within a package version, because generated code comes from the generator of the same package. A converter of your own may call it, and then follows the package: build it again with a new version.
Explicit Interface Implementations
Read(ref DynamoDbReader, AttributeType)
Reads the attribute value the reader is positioned on.
static IReadOnlyList<T> Read(ref DynamoDbReader reader, AttributeType type)
Parameters
readerDynamoDbReaderThe 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.
typeAttributeTypeThe 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
- IReadOnlyList<T>
The value.
Exceptions
- JsonException
typeis not List, or an element fails to read.
Write(DynamoDbWriter, IReadOnlyList<T>)
Writes a value as one complete attribute value, for example with WriteNumber<T>(T).
static void Write(DynamoDbWriter writer, IReadOnlyList<T> value)
Parameters
writerDynamoDbWriterThe 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.
valueIReadOnlyList<T>The value.
Exceptions
- ArgumentNullException
valueis null.