Class BinaryConverter
- Namespace
- ShapeShift.Json
- Assembly
- ShapeShift.Json.dll
Converts byte arrays as base64 JSON strings.
public sealed class BinaryConverter : ShapeShiftConverter<byte[], JsonEncoder, JsonDecoder>
- Inheritance
-
BinaryConverter
- Inherited Members
Methods
GetContract(ContractContext<JsonEncoder, JsonDecoder>)
Describes the serialized form that this converter produces and accepts.
public override DataContract? GetContract(ContractContext<JsonEncoder, JsonDecoder> context)
Parameters
contextContractContext<JsonEncoder, JsonDecoder>Services for describing other types that this converter composes with.
Returns
- DataContract
The contract for the data this converter reads and writes, or null if this converter does not describe itself.
Remarks
The default implementation returns null, which causes ShapeShift to describe the type with an UndocumentedContract rather than guess at a representation. Override this method so that schema consumers can understand your converter's output.
The returned contract must describe exactly what WriteObject(ref TEncoder, object?, SerializationContext<TEncoder, TDecoder>) emits.
Read(ref JsonDecoder, SerializationContext<JsonEncoder, JsonDecoder>)
public override byte[]? Read(ref JsonDecoder decoder, SerializationContext<JsonEncoder, JsonDecoder> context)
Parameters
decoderJsonDecodercontextSerializationContext<JsonEncoder, JsonDecoder>
Returns
- byte[]
Write(ref JsonEncoder, in byte[]?, SerializationContext<JsonEncoder, JsonDecoder>)
public override void Write(ref JsonEncoder encoder, in byte[]? value, SerializationContext<JsonEncoder, JsonDecoder> context)
Parameters
encoderJsonEncodervaluebyte[]contextSerializationContext<JsonEncoder, JsonDecoder>