JsonConverterAttribute Třída

Definice

Když je umístěn na vlastnost nebo typ, určuje typ převaděče, který se má použít.When placed on a property or type, specifies the converter type to use.

public ref class JsonConverterAttribute : System::Text::Json::Serialization::JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)]
public class JsonConverterAttribute : System.Text.Json.Serialization.JsonAttribute
public class JsonConverterAttribute : System.Text.Json.Serialization.JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)]
public class JsonConverterAttribute : System.Text.Json.Serialization.JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)>]
type JsonConverterAttribute = class
    inherit JsonAttribute
type JsonConverterAttribute = class
    inherit JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)>]
type JsonConverterAttribute = class
    inherit JsonAttribute
Public Class JsonConverterAttribute
Inherits JsonAttribute
Dědičnost
JsonConverterAttribute
Atributy

Poznámky

Zadaný typ převaděče musí být odvozen od JsonConverter .The specified converter type must derive from JsonConverter.

Při umístění na vlastnost se zadaný konvertor vždy použije.When placed on a property, the specified converter will always be used.

Při umístění na typ se zadaný konvertor použije, pokud se do kolekce nepřidá kompatibilní převaděč JsonSerializerOptions.Converters nebo pokud je JsonConverterAttribute vlastnost stejného typu jiná.When placed on a type, the specified converter will be used unless a compatible converter is added to the JsonSerializerOptions.Converters collection or there is another JsonConverterAttribute on a property of the same type.

Další informace najdete v tématu Postup zápisu vlastních převaděčů pro serializaci JSON.For more information, see How to write custom converters for JSON serialization.

Konstruktory

JsonConverterAttribute()

Inicializuje novou instanci JsonConverterAttribute .Initializes a new instance of JsonConverterAttribute.

JsonConverterAttribute(Type)

Inicializuje novou instanci JsonConverterAttribute se zadaným typem převaděče.Initializes a new instance of JsonConverterAttribute with the specified converter type.

Vlastnosti

ConverterType

Získá typ JsonConverterAttribute , nebo null Pokud byl vytvořen bez typu.Gets the type of the JsonConverterAttribute, or null if it was created without a type.

TypeId

Při implementaci v odvozené třídě získá jedinečný identifikátor Attribute .When implemented in a derived class, gets a unique identifier for this Attribute.

(Zděděno od Attribute)

Metody

CreateConverter(Type)

Pokud je přepsána v odvozené třídě a ConverterType je null , umožňuje odvozené třídě vytvořit, aby bylo JsonConverter možné předat další stav.When overridden in a derived class and ConverterType is null, allows the derived class to create a JsonConverter in order to pass additional state.

Equals(Object)

Vrací hodnotu, která určuje, zda je tato instance rovna zadanému objektu.Returns a value that indicates whether this instance is equal to a specified object.

(Zděděno od Attribute)
GetHashCode()

Vrátí hodnotu hash pro tuto instanci.Returns the hash code for this instance.

(Zděděno od Attribute)
GetType()

Získá Type aktuální instanci.Gets the Type of the current instance.

(Zděděno od Object)
IsDefaultAttribute()

Při přepsání v odvozené třídě označuje, zda je hodnota této instance výchozí hodnotou pro odvozenou třídu.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Zděděno od Attribute)
Match(Object)

Při přepsání v odvozené třídě vrátí hodnotu, která označuje, zda je tato instance rovna zadanému objektu.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Zděděno od Attribute)
MemberwiseClone()

Vytvoří kopii aktuálního seznamu Object .Creates a shallow copy of the current Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.Returns a string that represents the current object.

(Zděděno od Object)

Explicitní implementace rozhraní

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.Maps a set of names to a corresponding set of dispatch identifiers.

(Zděděno od Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Načte informace o typu pro objekt, který lze použít k získání informací o typu pro rozhraní.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Zděděno od Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Zděděno od Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.Provides access to properties and methods exposed by an object.

(Zděděno od Attribute)

Platí pro