Class UnionContract
- Namespace
- ShapeShift.Schema
- Assembly
- ShapeShift.dll
Describes a type with several known subtypes, each identified by a discriminator.
public sealed class UnionContract : DataContract
- Inheritance
-
UnionContract
- Inherited Members
Remarks
A union value is encoded as a two-element vector: the discriminator followed by the value. A null discriminator selects BaseType.
Constructors
UnionContract(Type, DataContract, IEnumerable<UnionCaseContract>)
Initializes a new instance of the UnionContract class.
public UnionContract(Type dataType, DataContract baseType, IEnumerable<UnionCaseContract> cases)
Parameters
dataTypeType- The .NET type that this contract describes.
baseTypeDataContractThe contract used when the discriminator is null.
casesIEnumerable<UnionCaseContract>The known cases of the union.
Properties
BaseType
Gets the contract used when the discriminator is null.
public DataContract BaseType { get; }
Property Value
Cases
Gets the known cases of the union.
public ImmutableArray<UnionCaseContract> Cases { get; }
Property Value
Kind
Gets the kind of this contract, which identifies the concrete subclass.
public override DataContractKind Kind { get; }
Property Value
ReferencedContracts
Gets the contracts that this contract directly refers to.
public override IEnumerable<DataContract> ReferencedContracts { get; }
Property Value
Remarks
The sequence may contain the same contract more than once, and (for recursive types) may transitively include this contract itself.