Table of Contents

Class DerivedTypeUnion

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

A non-generic abstract base class for a type union that is centered on a common base type.

public abstract class DerivedTypeUnion
Inheritance
DerivedTypeUnion
Derived
Inherited Members

Remarks

Users should create instances of the derived DerivedShapeMapping<TBase> or DerivedTypeMapping<TBase> classes to define unions at runtime, or use the CreateDisabled(Type) method to disable an attribute-described union.

Properties

BaseType

Gets the base union type.

public abstract Type BaseType { get; }

Property Value

Type

Disabled

Gets a value indicating whether the union behavior is disabled on the BaseType.

public virtual bool Disabled { get; }

Property Value

bool

The default value is false.

Remarks

As the default behavior is non-union behavior anyway, this property is primarily useful for forcing the serializer to ignore any and all DerivedTypeShapeAttribute that may be present on the BaseType.

Methods

CreateDisabled(Type)

Creates a DerivedTypeUnion instance that disables a derived type union that may be discovered from one or more DerivedTypeShapeAttribute that may be found on the given baseType.

public static DerivedTypeUnion CreateDisabled(Type baseType)

Parameters

baseType Type

The base type to treat as an ordinary class instead of the base of a union.

Returns

DerivedTypeUnion

The union disabling object.

ThrowIfFrozen()

Throws an InvalidOperationException if this instance has been frozen.

protected void ThrowIfFrozen()