TomlDerivedTypeAttribute Class

Registers a derived type for polymorphic TOML serialization.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
public sealed class TomlDerivedTypeAttribute : TomlAttribute
Inheritance
TomlAttribute TomlDerivedTypeAttribute

Constructors

NameDescription
TomlDerivedTypeAttribute(Type)Initializes a new instance of the TomlDerivedTypeAttribute class as the default derived type (no discriminator). When a type is registered without a discriminator, it becomes the default type used when the discriminator property is missing or does not match any registered type.
TomlDerivedTypeAttribute(Type, int)Initializes a new instance of the TomlDerivedTypeAttribute class with an integer discriminator.
TomlDerivedTypeAttribute(Type, string)Initializes a new instance of the TomlDerivedTypeAttribute class with a string discriminator.

TomlDerivedTypeAttribute overloads

TomlDerivedTypeAttribute(Type)

TomlDerivedTypeAttribute.cs

Initializes a new instance of the TomlDerivedTypeAttribute class as the default derived type (no discriminator). When a type is registered without a discriminator, it becomes the default type used when the discriminator property is missing or does not match any registered type.

public TomlDerivedTypeAttribute(Type derivedType)
Parameters
derivedType Type
The derived CLR type.

TomlDerivedTypeAttribute(Type, int)

TomlDerivedTypeAttribute.cs

Initializes a new instance of the TomlDerivedTypeAttribute class with an integer discriminator.

public TomlDerivedTypeAttribute(Type derivedType, int discriminator)
Parameters
derivedType Type
The derived CLR type.
discriminator int
The integer discriminator value (converted to string via invariant culture).

TomlDerivedTypeAttribute(Type, string)

TomlDerivedTypeAttribute.cs

Initializes a new instance of the TomlDerivedTypeAttribute class with a string discriminator.

public TomlDerivedTypeAttribute(Type derivedType, string discriminator)
Parameters
derivedType Type
The derived CLR type.
discriminator string
The discriminator value.

Properties

NameDescription
DerivedTypeGets the derived CLR type.
DiscriminatorGets the discriminator value, or null if this is the default derived type.

Gets the derived CLR type.

public Type DerivedType { get; }

Property value

Type

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

public string? Discriminator { get; }

Property value

string?