Class ValueObjectJsonRegistry
Namespace: AdCodicem.ValueObjects.Json
Assembly: AdCodicem.ValueObjects.Json.dll
Directory of the converters generated for the value objects of the loaded assemblies.
public static class ValueObjectJsonRegistry
Inheritance
object ← ValueObjectJsonRegistry
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
A source generator only ever sees the original compilation, never the output of another generator. The
[JsonConverter] attribute placed on a generated value object is therefore invisible to the
System.Text.Json generator, and a JsonSerializerContext would otherwise fall back to serializing the
value object as an object with properties.
This registry closes that gap. The value object generator emits a registration for every value object when
this package is referenced, and
Properties
Count
Gets the number of registered converters.
public static int Count { get; }
Property Value
Methods
Register<TSelf>(JsonConverter<TSelf>)
Registers the converter of a value object.
public static void Register<TSelf>(JsonConverter<TSelf> converter) where TSelf : struct
Parameters
converter JsonConverter<TSelf>
Converter to register.
Type Parameters
TSelf
Value object type.
TryGet(Type, out JsonConverter?)
Looks up the converter registered for a value object type.
public static bool TryGet(Type type, out JsonConverter? converter)
Parameters
type Type
Value object type.
converter JsonConverter?
The registered converter.
Returns
true when a converter is registered.