JsonSerializerOptions.GetTypeInfo(Type) 方法

定義

JsonTypeInfo取得目前 JsonSerializerOptions 實例解析的合約中繼資料。

public:
 System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ GetTypeInfo(Type ^ type);
public System.Text.Json.Serialization.Metadata.JsonTypeInfo GetTypeInfo (Type type);
member this.GetTypeInfo : Type -> System.Text.Json.Serialization.Metadata.JsonTypeInfo
Public Function GetTypeInfo (type As Type) As JsonTypeInfo

參數

type
Type

要解析合約中繼資料的類型。

傳回

針對 解析的 type 合約中繼資料。

例外狀況

typenull

type 對序列化無效。

備註

傳回的中繼資料可以向下轉型為 JsonTypeInfo<T> ,並與相關的 JsonSerializer 多載搭配使用。

JsonSerializerOptions如果實例遭到鎖定以進行修改,方法會傳回中繼資料的快取實例。

適用於