Class Marshaller<T> (2.48.0)

public class Marshaller<T> : object

Encapsulates the logic for serializing and deserializing messages.

Inheritance

Object > Marshaller<T>

Namespace

Grpc.Core

Assembly

Grpc.Core.Api.dll

Type Parameter

NameDescription
T

Constructors

Marshaller(Action<T, SerializationContext>, Func<DeserializationContext, T>)

public Marshaller(Action<T, SerializationContext> serializer, Func<DeserializationContext, T> deserializer)

Initializes a new marshaller from serialize/deserialize fuctions that can access serialization and deserialization context. Compared to the simple serializer/deserializer functions, using the contextual version provides more flexibility and can lead to increased efficiency (and better performance). Note: This constructor is part of an experimental API that can change or be removed without any prior notice.

Parameters
NameDescription
serializerAction<T, SerializationContext>

Function that will be used to serialize messages.

deserializerFunc<DeserializationContext, T>

Function that will be used to deserialize messages.

Marshaller(Func<T, Byte[]>, Func<Byte[], T>)

public Marshaller(Func<T, byte[]> serializer, Func<byte[], T> deserializer)

Initializes a new marshaller from simple serialize/deserialize functions.

Parameters
NameDescription
serializerFunc<T, Byte[]>

Function that will be used to serialize messages.

deserializerFunc<Byte[], T>

Function that will be used to deserialize messages.

Properties

ContextualDeserializer

public Func<DeserializationContext, T> ContextualDeserializer { get; }

Gets the serializer function. Note: experimental API that can change or be removed without any prior notice.

Property Value
TypeDescription
Func<DeserializationContext, T>

ContextualSerializer

public Action<T, SerializationContext> ContextualSerializer { get; }

Gets the serializer function. Note: experimental API that can change or be removed without any prior notice.

Property Value
TypeDescription
Action<T, SerializationContext>

Deserializer

public Func<byte[], T> Deserializer { get; }

Gets the deserializer function.

Property Value
TypeDescription
Func<Byte[], T>

Serializer

public Func<T, byte[]> Serializer { get; }

Gets the serializer function.

Property Value
TypeDescription
Func<T, Byte[]>