YamlTypeClassifierContext class
Provides immutable metadata to a YamlTypeClassifierFactory when creating a YamlTypeClassifier delegate.
Namespace: System.Text.Yaml.Serialization ยท Assembly: Styml.dll
public sealed class YamlTypeClassifierContext
Provides immutable metadata to a YamlTypeClassifierFactory when creating a YamlTypeClassifier delegate.
RemarksLink to this heading
The context carries a YamlTypeClassifierContext.Kind value indicating whether the classifier is being created for a union type or a polymorphic type. Exactly one of the two candidate lists is populated for any given context.
Instances are created internally by the serialization infrastructure. Users interact with the context through a YamlTypeClassifierFactory implementation.
PropertiesLink to this heading
DeclaringTypeLink to this heading
Gets the type being configured for classification.
public Type DeclaringType { get; }
For polymorphic types, this is the base class (e.g., Animal). For union types, this is the union type (e.g., IntOrString).
DerivedTypesLink to this heading
Gets the derived types of YamlTypeClassifierContext.DeclaringType.
public IReadOnlyList<YamlDerivedType> DerivedTypes { get; }
Non-empty when YamlTypeClassifierContext.DeclaringType is configured as a polymorphic type. The list mirrors YamlPolymorphismOptions.DerivedTypes; each entry may carry a YamlDerivedType.TypeDiscriminator string or integer.
KindLink to this heading
Gets the type of classifier metadata being configured.
public YamlTypeClassifierKind Kind { get; }
TypeDiscriminatorPropertyNameLink to this heading
Gets the YAML property name used for type discrimination (e.g., "$type", "kind").
public string? TypeDiscriminatorPropertyName { get; }
Populated from YamlPolymorphismOptions.TypeDiscriminatorPropertyName for polymorphic types. null for union types (unions don't use discriminator properties by default).
UnionCasesLink to this heading
Gets the union cases of YamlTypeClassifierContext.DeclaringType.
public IReadOnlyList<YamlUnionCaseInfo> UnionCases { get; }
Non-empty when YamlTypeClassifierContext.DeclaringType is configured as a union type. The list mirrors YamlTypeInfo.UnionCases on the resolved YamlTypeInfo.