Table of Contents

Method SerializeAsync

Namespace
AvroSharp.Azure.SchemaRegistry
Assembly
AvroSharp.Azure.SchemaRegistry.dll

SerializeAsync<TMessage, TData>(TData, CancellationToken)

Writes a value into a new message of type TMessage.

public virtual ValueTask<TMessage> SerializeAsync<TMessage, TData>(TData data, CancellationToken cancellationToken = default) where TMessage : MessageContent, new()

Parameters

data TData

The value.

cancellationToken CancellationToken

Cancels the registry call, if one is needed.

Returns

ValueTask<TMessage>

Type Parameters

TMessage

The message type, such as MessageContent, EventData or ServiceBusMessage.

TData

The value's type.

Exceptions

InvalidOperationException

The serializer has no group, or TData is not a type it can write.

ArgumentException

The value's schema has no name, which the registry needs.

SerializeAsync(object, Type?, Type?, CancellationToken)

Writes a value into a new message.

public virtual ValueTask<MessageContent> SerializeAsync(object data, Type? dataType = null, Type? messageType = null, CancellationToken cancellationToken = default)

Parameters

data object

The value.

dataType Type

The value's type, or null for its run-time type.

messageType Type

The message type: MessageContent (the default) or a type derived from it, with a public parameterless constructor.

cancellationToken CancellationToken

Cancels the registry call, if one is needed.

Returns

ValueTask<MessageContent>

Exceptions

InvalidOperationException

The serializer has no group, or the value is not of a type it can write.

ArgumentException

The value's schema has no name, or messageType is not a MessageContent.