Table of Contents

Class MessagePackOutputFormatter

Namespace
Nerdbank.MessagePack.AspNetCoreMvcFormatter
Assembly
Nerdbank.MessagePack.AspNetCoreMvcFormatter.dll

An output formatter for ASP.NET Core MVC that serializes strongly-typed objects into MessagePack content.

public class MessagePackOutputFormatter : OutputFormatter, IOutputFormatter, IApiResponseTypeMetadataProvider
Inheritance
MessagePackOutputFormatter
Implements
Inherited Members

Remarks

This formatter supports the "application/x-msgpack" media type and uses the provided ITypeShapeProvider to resolve type shapes for serialization with the specified MessagePackSerializer.

Constructors

MessagePackOutputFormatter(ITypeShapeProvider)

Initializes a new instance of the MessagePackOutputFormatter class with a default MessagePackSerializer.

public MessagePackOutputFormatter(ITypeShapeProvider typeShapeProvider)

Parameters

typeShapeProvider ITypeShapeProvider
The type shape provider used to resolve type shapes for serialization. This may be Default but is recommended to be a source generated type shape provider for better startup performance.

MessagePackOutputFormatter(ITypeShapeProvider, MessagePackSerializer)

Initializes a new instance of the MessagePackOutputFormatter class with the specified MessagePack serializer.

public MessagePackOutputFormatter(ITypeShapeProvider typeShapeProvider, MessagePackSerializer serializer)

Parameters

typeShapeProvider ITypeShapeProvider

The type shape provider used to resolve type shapes for serialization. This may be Default but is recommended to be a source generated type shape provider for better startup performance.

serializer MessagePackSerializer

The serializer to use.

Exceptions

ArgumentNullException

Thrown when serializer is null.

Methods

WriteResponseBodyAsync(OutputFormatterWriteContext)

Writes the response body.

public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context)

Parameters

context OutputFormatterWriteContext

The formatter context associated with the call.

Returns

Task

A task which can write the response body.