YamlUnionCaseInfo Class

Describes a single case of a C# union type to a YamlTypeClassifierFactory.

public sealed class YamlUnionCaseInfo

Constructors

NameDescription
YamlUnionCaseInfo(Type, YamlUnionCaseShape, IReadOnlyList<YamlUnionCaseProperty>?, bool)Initializes a new instance of the YamlUnionCaseInfo class.

YamlUnionCaseInfo(Type, YamlUnionCaseShape, IReadOnlyList<YamlUnionCaseProperty>?, bool)

YamlUnionCaseInfo.cs

Initializes a new instance of the YamlUnionCaseInfo class.

public YamlUnionCaseInfo(Type caseType, YamlUnionCaseShape shape, IReadOnlyList<YamlUnionCaseProperty>? properties = null, bool disallowUnmappedProperties = false)

Parameters

caseType Type
The declared case type.
shape YamlUnionCaseShape
The YAML shape the case is represented by.
properties IReadOnlyList<YamlUnionCaseProperty>?
The mapping keys declared by the case, or null when the case does not serialize as an object mapping.
disallowUnmappedProperties bool
Whether the case rejects mapping keys it does not declare.

Exceptions

ArgumentNullException
caseType is null.
ArgumentException
A property entry is null.

Properties

NameDescription
CaseTypeGets the declared case type.
DisallowUnmappedPropertiesGets a value indicating whether the case rejects mapping keys it does not declare.
HasObjectPropertiesGets a value indicating whether the case serializes as an object mapping whose keys are known. A mapping case backed by a dictionary has no declared keys and therefore reports false.
PropertiesGets the mapping keys declared by the case.
ShapeGets the YAML shape the case is represented by.

Gets the declared case type.

public Type CaseType { get; }

Property value

Type

DisallowUnmappedProperties

YamlUnionCaseInfo.cs

Gets a value indicating whether the case rejects mapping keys it does not declare.

public bool DisallowUnmappedProperties { get; }

Property value

bool

HasObjectProperties

YamlUnionCaseInfo.cs

Gets a value indicating whether the case serializes as an object mapping whose keys are known. A mapping case backed by a dictionary has no declared keys and therefore reports false.

public bool HasObjectProperties { get; }

Property value

bool

Gets the mapping keys declared by the case.

public IReadOnlyList<YamlUnionCaseProperty> Properties { get; }

Gets the YAML shape the case is represented by.

public YamlUnionCaseShape Shape { get; }

Property value

YamlUnionCaseShape