Table of Contents

Struct ConverterContext

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

Context in which a IMessagePackConverterFactory is invoked.

public struct ConverterContext
Inherited Members

Remarks

Provides access to other converters that may be required by the requested converter.

Properties

TypeShapeProvider

Gets the ITypeShapeProvider that can provide shapes for given types.

public readonly ITypeShapeProvider TypeShapeProvider { get; }

Property Value

ITypeShapeProvider

Methods

GetConverter(ITypeShape)

Gets a converter for a given type shape.

public MessagePackConverter GetConverter(ITypeShape typeShape)

Parameters

typeShape ITypeShape

The shape of the type to be converted.

Returns

MessagePackConverter

The converter.

Remarks

This method is intended only for use by custom converters in order to delegate conversion of sub-values.

Exceptions

InvalidOperationException

Thrown if no serialization operation is in progress.

GetConverter(Type, ITypeShapeProvider?)

Gets a converter for a given type shape.

public MessagePackConverter GetConverter(Type type, ITypeShapeProvider? provider = null)

Parameters

type Type

The type to be converted.

provider ITypeShapeProvider
The shape provider of T. This might be Default to use reflection-based shapes. It might also be the value of the GeneratedTypeShapeProvider static property on a witness class (a class on which GenerateShapeForAttribute<T> has been applied), although for source generated shapes, overloads that do not take an ITypeShapeProvider offer better performance. It can also come from TypeShapeProvider. A null value will be filled in with TypeShapeProvider.

Returns

MessagePackConverter

The converter.

Remarks

This method is intended only for use by custom converters in order to delegate conversion of sub-values.

Exceptions

InvalidOperationException

Thrown if no serialization operation is in progress.

GetConverter<T>()

Gets a converter for some type.

public MessagePackConverter<T> GetConverter<T>() where T : IShapeable<T>

Returns

MessagePackConverter<T>

The converter.

Type Parameters

T

The type for which a converter is required.

GetConverter<T>(ITypeShapeProvider?)

Gets a converter for a specific type.

public MessagePackConverter<T> GetConverter<T>(ITypeShapeProvider? provider)

Parameters

provider ITypeShapeProvider
The shape provider of T. This might be Default to use reflection-based shapes. It might also be the value of the GeneratedTypeShapeProvider static property on a witness class (a class on which GenerateShapeForAttribute<T> has been applied), although for source generated shapes, overloads that do not take an ITypeShapeProvider offer better performance. It can also come from TypeShapeProvider. A null value will be filled in with TypeShapeProvider.

Returns

MessagePackConverter<T>

The converter.

Type Parameters

T

The type to be converted.

Remarks

This method is intended only for use by custom converters in order to delegate conversion of sub-values.

Exceptions

InvalidOperationException

Thrown if no serialization operation is in progress.

GetConverter<T>(ITypeShape<T>)

Gets a converter for a given type shape.

public MessagePackConverter<T> GetConverter<T>(ITypeShape<T> typeShape)

Parameters

typeShape ITypeShape<T>

The shape of the type to be converted.

Returns

MessagePackConverter<T>

The converter.

Type Parameters

T

The type to be converted.

Remarks

This method is intended only for use by custom converters in order to delegate conversion of sub-values.

Exceptions

InvalidOperationException

Thrown if no serialization operation is in progress.

GetConverter<T, TProvider>()

Gets a converter for some type.

public MessagePackConverter<T> GetConverter<T, TProvider>() where TProvider : IShapeable<T>

Returns

MessagePackConverter<T>

The converter.

Type Parameters

T

The type for which a converter is required.

TProvider

The provider of the type's shape.