CrystalJsonTypeResolverChain

Namespace: SnowBank.Data.Json · class

Implements: ICrystalJsonTypeResolver

Collection that aggregates multiple smaller collections into a single chain

Constructors

CrystalJsonTypeResolverChain

CrystalJsonTypeResolverChain()

Methods

Append

CrystalJsonTypeResolverChain Append(ICrystalJsonTypeResolver resolver)

Adds a new type collection to this chain

  • resolver — Collection of types

Returns: The same chain instance

The order of appends is important for conflict resolution in case the same type is present in multiple collections. Collections are evaluated to last to first, will have priority against any previously added collection.

Clear

void Clear()

Remove all resolvers in this chain

Contains

bool Contains(ICrystalJsonTypeResolver resolver)

Tests if this chain already contains the given resolver

Create

static CrystalJsonTypeResolverChain Create()

Creates a new empty chain of type collections

static CrystalJsonTypeResolverChain Create(ICrystalJsonTypeResolver resolver)

Creates a new chain with the specified resolver as the root

  • resolver — First resolver in the chain

static CrystalJsonTypeResolverChain Create(ReadOnlySpan<ICrystalJsonTypeResolver> resolvers)

Creates a new chain with the specified type collections

  • resolvers — List of resolvers, in the same order as they would be appended to the chain using Append

TryGetConverterFor

bool TryGetConverterFor<T>(out IJsonConverter<T> converter)

Returns the converter for the given type in this collection

  • converter — Receives the converter for this type, if it is managed by this collection

Returns: true if this collection handles this type; otherwise, false

bool TryGetConverterFor(Type type, out IJsonConverter converter)

Returns the converter for the given type in this collection

  • type — Type of values that needs to be converted
  • converter — Receives the converter for this type, if it is managed by this collection

Returns: true if this collection handles this type; otherwise, false

TryResolveTypeDefinition

bool TryResolveTypeDefinition<T>(out CrystalJsonTypeDefinition definition)

Returns the type definition for the specified type

  • definition — Receives the definition for this type, if it is known by this resolver

Returns: true if the resolver can handle this type; otherwise, false

bool TryResolveTypeDefinition(Type type, out CrystalJsonTypeDefinition definition)

Returns the type definition for the specified type

  • type — Type to inspect
  • definition — Receives the definition for this type, if it is known by this resolver

Returns: true if the resolver can handle this type; otherwise, false