YamlDerivedType Class

Represents a derived type mapping for runtime polymorphic configuration.

public sealed class YamlDerivedType

Constructors

NameDescription
YamlDerivedType(Type)Initializes a new instance with no discriminator. When YamlDerivedType.Tag is also null, this derived type becomes the default when no discriminator or tag matches. When YamlDerivedType.Tag is set, this entry participates only in tag-based dispatch and does not become the default.
YamlDerivedType(Type, int)Initializes a new instance with an integer discriminator.
YamlDerivedType(Type, string)Initializes a new instance with a string discriminator.

YamlDerivedType overloads

YamlDerivedType(Type)

YamlDerivedType.cs

Initializes a new instance with no discriminator. When YamlDerivedType.Tag is also null, this derived type becomes the default when no discriminator or tag matches. When YamlDerivedType.Tag is set, this entry participates only in tag-based dispatch and does not become the default.

public YamlDerivedType(Type derivedType)
Parameters
derivedType Type
The derived CLR type.
Exceptions
ArgumentNullException
derivedType is null.

YamlDerivedType(Type, int)

YamlDerivedType.cs

Initializes a new instance with an integer discriminator.

public YamlDerivedType(Type derivedType, int discriminator)
Parameters
derivedType Type
The derived CLR type.
discriminator int
The integer discriminator value.
Exceptions
ArgumentNullException
derivedType is null.

YamlDerivedType(Type, string)

YamlDerivedType.cs

Initializes a new instance with a string discriminator.

public YamlDerivedType(Type derivedType, string discriminator)
Parameters
derivedType Type
The derived CLR type.
discriminator string
The discriminator value.
Exceptions
ArgumentNullException
derivedType or discriminator is null.

Properties

NameDescription
DerivedTypeGets the derived CLR type.
DiscriminatorGets the discriminator value, or null if this is the default derived type.
TagGets or sets an optional explicit YAML tag for the derived type.

Gets the derived CLR type.

public Type DerivedType { get; }

Property value

Type

Discriminator

YamlDerivedType.cs

Gets the discriminator value, or null if this is the default derived type.

public string? Discriminator { get; }

Property value

string?

Gets or sets an optional explicit YAML tag for the derived type.

public string? Tag { get; init; }

Property value

string?