Class DerivedTypeDuckTyping
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
Defines an experimental discriminator-free union identified by required serialized property names.
[Experimental("DuckTyping")]
public class DerivedTypeDuckTyping : DerivedTypeUnion
- Inheritance
-
DerivedTypeDuckTyping
- Inherited Members
Remarks
Deserialization buffers the value and rejects ambiguous or insufficient evidence rather than falling back to the base contract. A concrete base type is included as a case and must satisfy the same requirements as derived types. Required members are validated during construction; their serialized names depend on the serializer's naming policy and are resolved when its converter is created.
Constructors
DerivedTypeDuckTyping(ITypeShape, params ReadOnlySpan<ITypeShape>)
Initializes a new instance of the DerivedTypeDuckTyping class.
public DerivedTypeDuckTyping(ITypeShape baseShape, params ReadOnlySpan<ITypeShape> derivedTypeShapes)
Parameters
baseShapeITypeShapeThe base type shape.
derivedTypeShapesReadOnlySpan<ITypeShape>The concrete derived type shapes.
Exceptions
- ArgumentException
The cases are duplicated, not concrete or assignable, number fewer than two, or lack required object properties.
Properties
BaseType
Gets the base union type.
public override Type BaseType { get; }