YamlTypeClassifierContext Class
Describes the type a YamlTypeClassifierFactory is asked to classify.
public sealed class YamlTypeClassifierContextProperties
| Name | Description |
|---|---|
| DeclaringType | Gets the type being classified. |
| DerivedTypes | Gets the types derived from YamlTypeClassifierContext.DeclaringType, when it is a polymorphic type. |
| Kind | Gets the kind of the type being classified. |
| TypeDiscriminatorPropertyName | Gets the mapping key carrying the type discriminator, when YamlTypeClassifierContext.DeclaringType uses one. |
| UnionCases | Gets the cases declared by YamlTypeClassifierContext.DeclaringType, when it is a union type. |
DeclaringType
YamlTypeClassifierContext.csDerivedTypes
YamlTypeClassifierContext.csGets the types derived from YamlTypeClassifierContext.DeclaringType, when it is a polymorphic type.
public ReadOnlyCollection<YamlDerivedType> DerivedTypes { get; }Property value
Gets the kind of the type being classified.
public YamlTypeClassifierKind Kind { get; }Property value
TypeDiscriminatorPropertyName
YamlTypeClassifierContext.csGets the mapping key carrying the type discriminator, when YamlTypeClassifierContext.DeclaringType uses one.
public string? TypeDiscriminatorPropertyName { get; }Property value
UnionCases
YamlTypeClassifierContext.csGets the cases declared by YamlTypeClassifierContext.DeclaringType, when it is a union type.
public ReadOnlyCollection<YamlUnionCaseInfo> UnionCases { get; }Property value
Methods
| Name | Description |
|---|---|
| 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.csCreates a context describing a polymorphic type.
public static YamlTypeClassifierContext CreateForPolymorphicType(Type declaringType, IReadOnlyList<YamlDerivedType> derivedTypes, string? typeDiscriminatorPropertyName)Parameters
declaringTypeType- The base type.
derivedTypesIReadOnlyList<YamlDerivedType>- The types derived from
declaringType. typeDiscriminatorPropertyNamestring?- The mapping key carrying the type discriminator, when the type uses one.
Returns
YamlTypeClassifierContext The context to create a classifier from.
Exceptions
ArgumentNullExceptiondeclaringTypeorderivedTypesisnull.ArgumentException- A derived type entry is
null.
CreateForUnion(Type, IReadOnlyList<YamlUnionCaseInfo>)
YamlTypeClassifierContext.csCreates a context describing a C# union type.
public static YamlTypeClassifierContext CreateForUnion(Type declaringType, IReadOnlyList<YamlUnionCaseInfo> unionCases)Parameters
declaringTypeType- The union type.
unionCasesIReadOnlyList<YamlUnionCaseInfo>- The cases declared by
declaringType.
Returns
YamlTypeClassifierContext The context to create a classifier from.
Exceptions
ArgumentNullExceptiondeclaringTypeorunionCasesisnull.ArgumentException- A case entry is
null.