TomlDerivedTypeMappingAttribute Class

Registers a derived type mapping on a source-generated TomlSerializerContext, enabling cross-project polymorphism.

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

Constructors

NameDescription
TomlDerivedTypeMappingAttribute(Type, Type)Initializes a new instance of the TomlDerivedTypeMappingAttribute class with no discriminator.
TomlDerivedTypeMappingAttribute(Type, Type, int)Initializes a new instance of the TomlDerivedTypeMappingAttribute class with an integer discriminator.
TomlDerivedTypeMappingAttribute(Type, Type, string)Initializes a new instance of the TomlDerivedTypeMappingAttribute class with a string discriminator.

TomlDerivedTypeMappingAttribute overloads

TomlDerivedTypeMappingAttribute(Type, Type)

TomlDerivedTypeMappingAttribute.cs

Initializes a new instance of the TomlDerivedTypeMappingAttribute class with no discriminator.

public TomlDerivedTypeMappingAttribute(Type baseType, Type derivedType)
Parameters
baseType Type
The polymorphic base type.
derivedType Type
The derived CLR type.

TomlDerivedTypeMappingAttribute(Type, Type, int)

TomlDerivedTypeMappingAttribute.cs

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

public TomlDerivedTypeMappingAttribute(Type baseType, Type derivedType, int discriminator)
Parameters
baseType Type
The polymorphic base type.
derivedType Type
The derived CLR type.
discriminator int
The integer discriminator value.

TomlDerivedTypeMappingAttribute(Type, Type, string)

TomlDerivedTypeMappingAttribute.cs

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

public TomlDerivedTypeMappingAttribute(Type baseType, Type derivedType, string discriminator)
Parameters
baseType Type
The polymorphic base type.
derivedType Type
The derived CLR type.
discriminator string
The discriminator value.

Properties

NameDescription
BaseTypeGets the polymorphic base type.
DerivedTypeGets the derived CLR type.
DiscriminatorGets the discriminator value, or null when this is the default derived type.

Gets the polymorphic base type.

public Type BaseType { get; }

Property value

Type

Gets the derived CLR type.

public Type DerivedType { get; }

Property value

Type

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

public string? Discriminator { get; }

Property value

string?