JsonSerializerOptions.TryGetTypeInfo 方法

定义

重载

名称 说明
TryGetTypeInfo(Type, JsonTypeInfo)

尝试获取 JsonTypeInfo 由当前 JsonSerializerOptions 实例解析的协定元数据。

TryGetTypeInfo<T>(JsonTypeInfo<T>)

TryGetTypeInfo(Type, JsonTypeInfo)

Source:
JsonSerializerOptions.Caching.cs
Source:
JsonSerializerOptions.Caching.cs
Source:
JsonSerializerOptions.Caching.cs
Source:
JsonSerializerOptions.Caching.cs
Source:
JsonSerializerOptions.Caching.cs
Source:
JsonSerializerOptions.Caching.cs

尝试获取 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 无法解析协定。

返回

如果找到了合同 ,则为 ;否则为 a0>。

例外

typenull

type 对序列化无效。

注解

返回的元数据可以向下转换到 JsonTypeInfo<T> 相关重载并将其与相关 JsonSerializer 重载一起使用。

JsonSerializerOptions如果实例被锁定进行修改,该方法将返回元数据的缓存实例。

适用于

TryGetTypeInfo<T>(JsonTypeInfo<T>)

Source:
JsonSerializerOptions.Caching.cs
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>

返回

适用于