AIJsonUtilities.AddAIContentType Method

Definition

Overloads

AddAIContentType(JsonSerializerOptions, Type, String)

Adds a custom content type to the polymorphic configuration for AIContent.

AddAIContentType<TContent>(JsonSerializerOptions, String)

Adds a custom content type to the polymorphic configuration for AIContent.

AddAIContentType(JsonSerializerOptions, Type, String)

Adds a custom content type to the polymorphic configuration for AIContent.

C#
public static void AddAIContentType(this System.Text.Json.JsonSerializerOptions options, Type contentType, string typeDiscriminatorId);

Parameters

options
JsonSerializerOptions

The options instance to configure.

contentType
Type

The custom content type to configure.

typeDiscriminatorId
String

The type discriminator id for the content type.

Exceptions

options, contentType, or typeDiscriminatorId is null.

contentType is a built-in content type or does not derived from AIContent.

options is a read-only instance.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

AddAIContentType<TContent>(JsonSerializerOptions, String)

Adds a custom content type to the polymorphic configuration for AIContent.

C#
public static void AddAIContentType<TContent>(this System.Text.Json.JsonSerializerOptions options, string typeDiscriminatorId) where TContent : Microsoft.Extensions.AI.AIContent;

Type Parameters

TContent

The custom content type to configure.

Parameters

options
JsonSerializerOptions

The options instance to configure.

typeDiscriminatorId
String

The type discriminator id for the content type.

Exceptions

options or typeDiscriminatorId is null.

TContent is a built-in content type.

options is a read-only instance.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)