Table of Contents

Method Serialize

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

Serialize<TMessage, TData>(TData, CancellationToken)

Writes a value into a new message of type TMessage.

public virtual TMessage Serialize<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

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.

Serialize(object, Type?, Type?, CancellationToken)

Writes a value into a new message.

public virtual MessageContent Serialize(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

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.