Table of Contents

Class KnownSubTypeAttribute<TSubType, TShapeProvider>

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

Specifies that where the class to which this attribute is applied is the declared type in an object graph that certain derived types are recorded in the serialized data as well and allowed to be deserialized back as their derived types.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
public class KnownSubTypeAttribute<TSubType, TShapeProvider> : Attribute where TShapeProvider : IShapeable<TSubType>

Type Parameters

TSubType

A class derived from the one to which this attribute is affixed.

TShapeProvider

The class that serves as the shape provider for TSubType.

Inheritance
KnownSubTypeAttribute<TSubType, TShapeProvider>
Derived
Inherited Members

Remarks

A type with one or more of these attributes applied serializes to a different schema than the same type without any attributes applied. The serialized data will include a special header that indicates the runtime type. Consider version compatibility issues when adding the first or removing the last attribute from a type.

Each type referenced by this attribute must have GenerateShapeAttribute applied to it or a witness class.

Constructors

KnownSubTypeAttribute(int)

Specifies that where the class to which this attribute is applied is the declared type in an object graph that certain derived types are recorded in the serialized data as well and allowed to be deserialized back as their derived types.

public KnownSubTypeAttribute(int alias)

Parameters

alias int

A value that identifies the subtype in the serialized data. Must be unique among all the attributes applied to the same class.

Remarks

A type with one or more of these attributes applied serializes to a different schema than the same type without any attributes applied. The serialized data will include a special header that indicates the runtime type. Consider version compatibility issues when adding the first or removing the last attribute from a type.

Each type referenced by this attribute must have GenerateShapeAttribute applied to it or a witness class.

Properties

Alias

Gets a value that identifies the subtype in the serialized data. Must be unique among all the attributes applied to the same class.

public int Alias { get; }

Property Value

int