YamlTypeClassification Class

Applies the YamlSerializerOptions.TypeClassifiers of a reader to a YAML payload.

public static class YamlTypeClassification

Remarks

This type supports the serializer infrastructure and is not intended to be used directly from your code.

Methods

NameDescription
Classify(YamlReader, YamlTypeClassifierContext, string?)Selects the type matching the value reader is positioned on, when a classifier is registered for the type described by context.
ClassifyBufferedNode(YamlReader, string, YamlTypeClassifierContext)Selects the type matching an already buffered value, when a classifier is registered for the type described by context.

Classify(YamlReader, YamlTypeClassifierContext, string?)

YamlTypeClassification.cs

Selects the type matching the value reader is positioned on, when a classifier is registered for the type described by context.

public static Type? Classify(YamlReader reader, YamlTypeClassifierContext context, out string? bufferedNode)

Parameters

reader YamlReader
The reader positioned at the start of the value.
context YamlTypeClassifierContext
The type to classify and the candidates to select from.
bufferedNode string?
Receives the buffered YAML of the value when a classifier ran, or null when no classifier is registered. Classification reads the value, so the caller must deserialize from a reader created over the buffered YAML rather than from reader.

Returns

Type? The selected type, or null when no classifier is registered or the value cannot be classified.

Exceptions

ArgumentNullException
reader or context is null.

ClassifyBufferedNode(YamlReader, string, YamlTypeClassifierContext)

YamlTypeClassification.cs

Selects the type matching an already buffered value, when a classifier is registered for the type described by context.

public static Type? ClassifyBufferedNode(YamlReader reader, string bufferedNode, YamlTypeClassifierContext context)

Parameters

reader YamlReader
The reader the value was buffered from, used for its options.
bufferedNode string
The buffered YAML of the value to classify.
context YamlTypeClassifierContext
The type to classify and the candidates to select from.

Returns

Type? The selected type, or null when no classifier is registered or the value cannot be classified.

Exceptions

ArgumentNullException
reader, bufferedNode, or context is null.