Sdílet prostřednictvím


TypeDiscriminatorAttribute Class

Definition

Used with the DiscriminatedTypeJsonConverter<TBase> to define the types in a hierarchy and their associated discriminator value. Apply this to the base type of the type hierarchy, one for each subtype. When the base type is concrete and might also be serialized to JSON, this should also be applied to the base type itself.

public ref class TypeDiscriminatorAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed class TypeDiscriminatorAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
type TypeDiscriminatorAttribute = class
    inherit Attribute
Public NotInheritable Class TypeDiscriminatorAttribute
Inherits Attribute
Inheritance
TypeDiscriminatorAttribute
Attributes

Constructors

TypeDiscriminatorAttribute(Type, String)

Initializes a new instance of the TypeDiscriminatorAttribute class.

TypeDiscriminatorAttribute(Type)

Initializes a new instance of the TypeDiscriminatorAttribute class, using the short name of the type as the discriminator value.

Properties

Type

Gets the type represented by the discriminator value.

Value

Gets the discriminator value that represents the type.

Applies to