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
dataTDataThe value.
cancellationTokenCancellationTokenCancels the registry call, if one is needed.
Returns
- TMessage
Type Parameters
TMessageThe message type, such as MessageContent,
EventDataorServiceBusMessage.TDataThe value's type.
Exceptions
- InvalidOperationException
The serializer has no group, or
TDatais 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
dataobjectThe value.
dataTypeTypeThe value's type, or null for its run-time type.
messageTypeTypeThe message type: MessageContent (the default) or a type derived from it, with a public parameterless constructor.
cancellationTokenCancellationTokenCancels the registry call, if one is needed.
Returns
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
messageTypeis not a MessageContent.