Class StateJsonConverter<TRecord, TState>
- Namespace
- Chronicler
- Assembly
- Chronicler.dll
Serializes and deserializes an object through its canonical state value.
public sealed class StateJsonConverter<TRecord, TState> : JsonConverter<TRecord> where TRecord : class, IStateBacked<TState>
Type Parameters
TRecordThe state-backed record type.
TStateThe serializable state type.
- Inheritance
-
JsonConverter<TRecord>StateJsonConverter<TRecord, TState>
- Inherited Members
Constructors
StateJsonConverter(Func<TState, TRecord>)
Creates a converter that restores records from serialized state using the supplied factory.
public StateJsonConverter(Func<TState, TRecord> factory)
Parameters
factoryFunc<TState, TRecord>
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
public override TRecord Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReadertypeToConvertTypeoptionsJsonSerializerOptions
Returns
- TRecord
Write(Utf8JsonWriter, TRecord, JsonSerializerOptions)
public override void Write(Utf8JsonWriter writer, TRecord value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWritervalueTRecordoptionsJsonSerializerOptions