JsonSerializerOptions.TryGetTypeInfo 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| TryGetTypeInfo(Type, JsonTypeInfo) |
嘗試讓 JsonTypeInfo 目前 JsonSerializerOptions 實例解決合約的元資料。 |
| TryGetTypeInfo<T>(JsonTypeInfo<T>) |
TryGetTypeInfo(Type, JsonTypeInfo)
嘗試讓 JsonTypeInfo 目前 JsonSerializerOptions 實例解決合約的元資料。
public:
bool TryGetTypeInfo(Type ^ type, [Runtime::InteropServices::Out] System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ % typeInfo);
public bool TryGetTypeInfo(Type type, out System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo);
member this.TryGetTypeInfo : Type * JsonTypeInfo -> bool
Public Function TryGetTypeInfo (type As Type, ByRef typeInfo As JsonTypeInfo) As Boolean
參數
- type
- Type
要解決合約元資料的類型。
- typeInfo
- JsonTypeInfo
當此方法回傳時,包含已解決的合約中繼資料,或 null 若合約無法解決。
傳回
true 如果找到合約 type ,或其他 false 情況。
例外狀況
type 是 null。
type 不適用於序列化。
備註
回傳的元資料可以下傳到 JsonTypeInfo<T> 相關 JsonSerializer 超載區並使用。
若 JsonSerializerOptions 實例被鎖定以進行修改,方法會回傳一個快取的實例作為元資料。
適用於
TryGetTypeInfo<T>(JsonTypeInfo<T>)
public:
generic <typename T>
bool TryGetTypeInfo([Runtime::InteropServices::Out] System::Text::Json::Serialization::Metadata::JsonTypeInfo<T> ^ % typeInfo);
public bool TryGetTypeInfo<T>(out System.Text.Json.Serialization.Metadata.JsonTypeInfo<T>? typeInfo);
member this.TryGetTypeInfo : JsonTypeInfo -> bool
Public Function TryGetTypeInfo(Of T) (ByRef typeInfo As JsonTypeInfo(Of T)) As Boolean
類型參數
- T
參數
- typeInfo
- JsonTypeInfo<T>