YamlDerivedTypeMappingAttribute Class
Registers a derived type mapping on a source-generated context, enabling cross-project polymorphism.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class YamlDerivedTypeMappingAttribute : YamlAttribute- Inheritance
YamlAttributeYamlDerivedTypeMappingAttribute
Constructors
| Name | Description |
|---|---|
| YamlDerivedTypeMappingAttribute(Type, Type) | Initializes a new instance with no discriminator, marking this derived type as the default when no discriminator matches. |
| YamlDerivedTypeMappingAttribute(Type, Type, int) | Initializes a new instance with an integer discriminator. |
| YamlDerivedTypeMappingAttribute(Type, Type, string) | Initializes a new instance with a string discriminator. |
YamlDerivedTypeMappingAttribute overloads
YamlDerivedTypeMappingAttribute(Type, Type)
YamlDerivedTypeMappingAttribute.csInitializes a new instance with no discriminator, marking this derived type as the default when no discriminator matches.
YamlDerivedTypeMappingAttribute(Type, Type, int)
YamlDerivedTypeMappingAttribute.csInitializes a new instance with an integer discriminator.
Parameters
baseTypeType- The polymorphic base type.
derivedTypeType- The derived CLR type.
discriminatorint- The integer discriminator value.
Exceptions
ArgumentNullExceptionbaseTypeorderivedTypeisnull.
YamlDerivedTypeMappingAttribute(Type, Type, string)
YamlDerivedTypeMappingAttribute.csInitializes a new instance with a string discriminator.
Parameters
baseTypeType- The polymorphic base type.
derivedTypeType- The derived CLR type.
discriminatorstring- The discriminator value.
Exceptions
ArgumentNullExceptionbaseType,derivedType, ordiscriminatorisnull.
Properties
| Name | Description |
|---|---|
| BaseType | Gets the polymorphic base type. |
| DerivedType | Gets the derived CLR type. |
| Discriminator | Gets the discriminator value, or null if this is the default derived type. |
| Tag | Gets or sets an optional explicit YAML tag for the derived type. |