Rediger

Del via


JsonSerializerOptions.TryGetTypeInfo Method

Definition

Overloads

Name Description
TryGetTypeInfo(Type, JsonTypeInfo)

Tries to get the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.

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

Tries to get the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.

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

Parameters

type
Type

The type to resolve contract metadata for.

typeInfo
JsonTypeInfo

When this method returns, contains the resolved contract metadata, or null if the contract could not be resolved.

Returns

true if a contract for type was found, or false otherwise.

Exceptions

type is null.

type is not valid for serialization.

Remarks

Returned metadata can be downcast to JsonTypeInfo<T> and used with the relevant JsonSerializer overloads.

If the JsonSerializerOptions instance is locked for modification, the method will return a cached instance for the metadata.

Applies to

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

Type Parameters

T

Parameters

typeInfo
JsonTypeInfo<T>

Returns

Applies to