Table of Contents

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

dataType Type
The .NET type that this contract describes.
baseType DataContract

The contract used when the discriminator is null.

cases IEnumerable<UnionCaseContract>

The known cases of the union.

Properties

BaseType

Gets the contract used when the discriminator is null.

public DataContract BaseType { get; }

Property Value

DataContract

Cases

Gets the known cases of the union.

public ImmutableArray<UnionCaseContract> Cases { get; }

Property Value

ImmutableArray<UnionCaseContract>

Kind

Gets the kind of this contract, which identifies the concrete subclass.

public override DataContractKind Kind { get; }

Property Value

DataContractKind

ReferencedContracts

Gets the contracts that this contract directly refers to.

public override IEnumerable<DataContract> ReferencedContracts { get; }

Property Value

IEnumerable<DataContract>

Remarks

The sequence may contain the same contract more than once, and (for recursive types) may transitively include this contract itself.