Class ValueObjectContractResolver
Namespace: AdCodicem.ValueObjects.NewtonsoftJson
Assembly: AdCodicem.ValueObjects.NewtonsoftJson.dll
Resolves each value object, and its nullable type, to a contract carrying
public sealed class ValueObjectContractResolver : IContractResolver
Inheritance
object ← ValueObjectContractResolver
Implements
IContractResolver
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
It is for code that hands Newtonsoft.Json a contract resolver alone, with no serializer settings to add the
converter to: settings take AddValueObjectsNewtonsoftJson() wraps a resolver.
A type [JsonConverter] on the type names, is answered as it is. The wrapped resolver's contracts are never changed:
its cache may be shared by every instance of its type, as
The contract of a type holding value objects stays the wrapped resolver's, and Newtonsoft.Json keeps the contract of each of its members on it, from the first time a serializer reads or writes that member. A serializer over this resolver and another over the same wrapped resolver therefore see each other's member contracts, in whichever order they first run. Wrap a resolver no other serializer uses, as the parameterless constructor does: never MVC's default one, which is a single instance shared by every set of MVC's serializer settings in the process.
A contract's converter wins over the converters the serializer settings name: an application's own converter for a
value object in [JsonConverter] instead.
Given to a JSON Patch document of Microsoft.AspNetCore.JsonPatch as its ContractResolver, it is what the
document converts a value with. JSON Patch reads the value again under settings of its own, which drop
ValueObjectJsonPatchExtensions.TryApplyTo, in AdCodicem.ValueObjects.AspNetCore.NewtonsoftJson, reads every
value through the rules, with their codes, and needs no resolver.
Constructors
ValueObjectContractResolver()
Initializes a new instance of the
public ValueObjectContractResolver()
ValueObjectContractResolver(IContractResolver)
Initializes a new instance of the
public ValueObjectContractResolver(IContractResolver inner)
Parameters
inner IContractResolver
The resolver of every other type.
Exceptions
inner is null.
Properties
Inner
Gets the resolver it wraps.
public IContractResolver Inner { get; }
Property Value
IContractResolver
Methods
ResolveContract(Type)
Resolves the contract for a given type.
public JsonContract ResolveContract(Type type)
Parameters
type Type
The type to resolve a contract for.
Returns
JsonContract
The contract for a given type.
Exceptions
type is null.