Table of Contents

Class ByteArrayConverter

Namespace
Breeze.Core
Assembly
Breeze.Core.dll

only needed because this functionality seems to be broken in JSON.NET 10.0.3

public class ByteArrayConverter : JsonConverter
Inheritance
JsonConverter
ByteArrayConverter
Inherited Members
JsonConverter.CanRead

Properties

CanWrite

This converter writes as well as reads.

public override bool CanWrite { get; }

Property Value

bool

Methods

CanConvert(Type)

Handles byte[] and nothing else.

public override bool CanConvert(Type objectType)

Parameters

objectType Type

The type being considered.

Returns

bool

True for byte[].

ReadJson(JsonReader, Type, object?, JsonSerializer)

Read a byte array from base64, accepting either a bare string or an object carrying "$value".

public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)

Parameters

reader JsonReader

The reader positioned at the value.

objectType Type

The target type.

existingValue object

Any value already present. Unused.

serializer JsonSerializer

The serializer in use.

Returns

object

The decoded bytes, or null for a JSON null.

Exceptions

JsonSerializationException

The value is neither a string nor an object with "$value".

WriteJson(JsonWriter, object?, JsonSerializer)

Write a byte array as a base64 string.

public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)

Parameters

writer JsonWriter

The writer to write to.

value object

The byte array. Json.NET handles nulls itself and never passes one here.

serializer JsonSerializer

The serializer in use.