YamlTypeClassifierContext Class

Describes the type a YamlTypeClassifierFactory is asked to classify.

public sealed class YamlTypeClassifierContext

Properties

NameDescription
DeclaringTypeGets the type being classified.
DerivedTypesGets the types derived from YamlTypeClassifierContext.DeclaringType, when it is a polymorphic type.
KindGets the kind of the type being classified.
TypeDiscriminatorPropertyNameGets the mapping key carrying the type discriminator, when YamlTypeClassifierContext.DeclaringType uses one.
UnionCasesGets the cases declared by YamlTypeClassifierContext.DeclaringType, when it is a union type.

Gets the type being classified.

public Type DeclaringType { get; }

Property value

Type

Gets the types derived from YamlTypeClassifierContext.DeclaringType, when it is a polymorphic type.

public ReadOnlyCollection<YamlDerivedType> DerivedTypes { get; }

Gets the kind of the type being classified.

public YamlTypeClassifierKind Kind { get; }

TypeDiscriminatorPropertyName

YamlTypeClassifierContext.cs

Gets the mapping key carrying the type discriminator, when YamlTypeClassifierContext.DeclaringType uses one.

public string? TypeDiscriminatorPropertyName { get; }

Property value

string?

Gets the cases declared by YamlTypeClassifierContext.DeclaringType, when it is a union type.

public ReadOnlyCollection<YamlUnionCaseInfo> UnionCases { get; }

Methods

NameDescription
CreateForPolymorphicType(Type, IReadOnlyList<YamlDerivedType>, string?)Creates a context describing a polymorphic type.
CreateForUnion(Type, IReadOnlyList<YamlUnionCaseInfo>)Creates a context describing a C# union type.

CreateForPolymorphicType(Type, IReadOnlyList<YamlDerivedType>, string?)

YamlTypeClassifierContext.cs

Creates a context describing a polymorphic type.

public static YamlTypeClassifierContext CreateForPolymorphicType(Type declaringType, IReadOnlyList<YamlDerivedType> derivedTypes, string? typeDiscriminatorPropertyName)

Parameters

declaringType Type
The base type.
derivedTypes IReadOnlyList<YamlDerivedType>
The types derived from declaringType.
typeDiscriminatorPropertyName string?
The mapping key carrying the type discriminator, when the type uses one.

Returns

YamlTypeClassifierContext The context to create a classifier from.

Exceptions

ArgumentNullException
declaringType or derivedTypes is null.
ArgumentException
A derived type entry is null.

CreateForUnion(Type, IReadOnlyList<YamlUnionCaseInfo>)

YamlTypeClassifierContext.cs

Creates a context describing a C# union type.

public static YamlTypeClassifierContext CreateForUnion(Type declaringType, IReadOnlyList<YamlUnionCaseInfo> unionCases)

Parameters

declaringType Type
The union type.
unionCases IReadOnlyList<YamlUnionCaseInfo>
The cases declared by declaringType.

Returns

YamlTypeClassifierContext The context to create a classifier from.

Exceptions

ArgumentNullException
declaringType or unionCases is null.
ArgumentException
A case entry is null.