JsonSerializerOptions.AddContext<TContext> Method

Definition

Binds current JsonSerializerOptions instance with a new instance of the specified JsonSerializerContext type.

public:
generic <typename TContext>
 where TContext : System::Text::Json::Serialization::JsonSerializerContextgcnew() void AddContext();
public void AddContext<TContext> () where TContext : System.Text.Json.Serialization.JsonSerializerContext, new();
member this.AddContext : unit -> unit (requires 'Context :> System.Text.Json.Serialization.JsonSerializerContext and 'Context : (new : unit -> 'Context))
Public Sub AddContext(Of TContext As {JsonSerializerContextNew}) ()

Type Parameters

TContext

The generic definition of the specified context type.

Remarks

When serializing and deserializing types using the options instance, metadata for the types will be fetched from the context instance.

Applies to