YamlPolymorphicAttribute Class
Marks a base type as polymorphic for YAML serialization.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public sealed class YamlPolymorphicAttribute : YamlAttribute- Inheritance
YamlAttributeYamlPolymorphicAttribute
Constructors
| Name | Description |
|---|---|
| YamlPolymorphicAttribute() |
YamlPolymorphicAttribute()
YamlPolymorphicAttribute.cspublic YamlPolymorphicAttribute()No documentation is available.
Properties
| Name | Description |
|---|---|
| DiscriminatorStyle | Gets or sets the discriminator style. |
| InferClosedTypePolymorphism | Gets or sets a value indicating whether derived type registrations are inferred from the compiler-provided metadata of a closed type hierarchy. |
| TypeDiscriminatorPropertyName | Gets or sets the discriminator property name. |
| UnknownDerivedTypeHandling | Gets or sets behavior when an unknown derived type discriminator is encountered. |
DiscriminatorStyle
YamlPolymorphicAttribute.csGets or sets the discriminator style.
public YamlTypeDiscriminatorStyle DiscriminatorStyle { get; set; }Property value
InferClosedTypePolymorphism
YamlPolymorphicAttribute.csGets or sets a value indicating whether derived type registrations are inferred from the compiler-provided metadata of a closed type hierarchy.
public bool InferClosedTypePolymorphism { get; set; }Property value
Remarks
Setting this property overrides YamlPolymorphismOptions.InferClosedTypePolymorphism for the annotated type, so an explicit false suppresses inference even when it is enabled on the serializer options. When the property is left unset the value from the options is used.
Inference is skipped for a type that declares explicit YamlDerivedTypeAttribute registrations. Setting this property to true on a type that is not declared closed throws an InvalidOperationException.
TypeDiscriminatorPropertyName
YamlPolymorphicAttribute.csUnknownDerivedTypeHandling
YamlPolymorphicAttribute.csGets or sets behavior when an unknown derived type discriminator is encountered.
public YamlUnknownDerivedTypeHandling UnknownDerivedTypeHandling { get; set; }Property value
YamlUnknownDerivedTypeHandling
Remarks
When set to a value other than YamlUnknownDerivedTypeHandling.Unspecified, this overrides the value from YamlPolymorphismOptions.UnknownDerivedTypeHandling and any value from JsonPolymorphicAttribute.