Class Marshaller<T>
Encapsulates the logic for serializing and deserializing messages.
Inheritance
Inherited Members
Namespace: Grpc.Core
Assembly: Grpc.Core.Api.dll
Syntax
public class Marshaller<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
Marshaller(Action<T, SerializationContext>, Func<DeserializationContext, T>)
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.
Declaration
public Marshaller(Action<T, SerializationContext> serializer, Func<DeserializationContext, T> deserializer)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T, SerializationContext> | serializer | Function that will be used to serialize messages. |
System.Func<DeserializationContext, T> | deserializer | Function that will be used to deserialize messages. |
Marshaller(Func<T, Byte[]>, Func<Byte[], T>)
Initializes a new marshaller from simple serialize/deserialize functions.
Declaration
public Marshaller(Func<T, byte[]> serializer, Func<byte[], T> deserializer)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.Byte[]> | serializer | Function that will be used to serialize messages. |
System.Func<System.Byte[], T> | deserializer | Function that will be used to deserialize messages. |
Properties
ContextualDeserializer
Gets the serializer function. Note: experimental API that can change or be removed without any prior notice.
Declaration
public Func<DeserializationContext, T> ContextualDeserializer { get; }
Property Value
Type | Description |
---|---|
System.Func<DeserializationContext, T> |
ContextualSerializer
Gets the serializer function. Note: experimental API that can change or be removed without any prior notice.
Declaration
public Action<T, SerializationContext> ContextualSerializer { get; }
Property Value
Type | Description |
---|---|
System.Action<T, SerializationContext> |
Deserializer
Gets the deserializer function.
Declaration
public Func<byte[], T> Deserializer { get; }
Property Value
Type | Description |
---|---|
System.Func<System.Byte[], T> |
Serializer
Gets the serializer function.
Declaration
public Func<T, byte[]> Serializer { get; }
Property Value
Type | Description |
---|---|
System.Func<T, System.Byte[]> |