YamlTypeInfo<T> class
Provides YAML serialization-related metadata about a type.
Namespace: System.Text.Yaml.Serialization.Metadata ยท Assembly: Styml.dll
public sealed class YamlTypeInfo<T> : YamlTypeInfo
Inheritance: object โ YamlTypeInfo โ YamlTypeInfo
Provides YAML serialization-related metadata about a type.
Type parameters
T: The generic definition of the type.
PropertiesLink to this heading
CreateObjectLink to this heading
Gets or sets a parameterless factory to be used on deserialization.
public Func<T?>? CreateObject { get; set; }
| Exception | Condition |
|---|---|
| InvalidOperationException | The YamlTypeInfo instance has been locked for further modification. -or- A parameterless factory is not supported for the current metadata YamlTypeInfo.Kind. |
If set to null, any attempt to deserialize instances of the given type will fail at runtime. For contracts originating from DefaultYamlTypeInfoResolver or YamlSerializerContext, types with a single default constructor or default constructors annotated with YamlConstructorAttribute will be mapped to this delegate.
UnionConstructorLink to this heading
Gets or sets the strongly-typed delegate that constructs a union instance from a case type and case value.
public Func<Type, object?, T?>? UnionConstructor { get; set; }
Setting this property also updates the weakly-typed YamlTypeInfo.UnionConstructor on the base type.
The delegate takes a Type parameter for disambiguation when overlapping case types exist (e.g., Labrador : Dog). For value-type unions, using this strongly-typed overload avoids boxing the result.
The delegate is invoked with a null case value when the converter encounters a YAML YamlTokenType.Null token, in which case the case-type argument is unspecified and should be ignored. See YamlTypeInfo.UnionConstructor for the full null-handling contract.
UnionDeconstructorLink to this heading
Gets or sets the strongly-typed delegate that deconstructs a union instance into its case type and case value.
public Func<T?, ValueTuple<Type?, object?>>? UnionDeconstructor { get; set; }
Setting this property also updates the weakly-typed YamlTypeInfo.UnionDeconstructor on the base type. Refer to that property's remarks for the full (CaseType, CaseValue) contract โ including the role of a null``CaseType as the discriminator for the canonical null-union state.
For value-type unions, using this strongly-typed overload avoids boxing the union instance.