Class SchemaSourceGenerationContext
- Namespace
- GenerativeAI.Types
- Assembly
- GenerativeAI.dll
The SchemaSourceGenerationContext class is a custom source generation context for improving the performance of JSON serialization and deserialization. This is achieved by leveraging the JsonSourceGenerationOptionsAttribute to configure source generation options and define types for serialization at compile-time.
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Schema))]
public class SchemaSourceGenerationContext : JsonSerializerContext, IJsonTypeInfoResolver
- Inheritance
-
SchemaSourceGenerationContext
- Implements
- Inherited Members
- Extension Methods
Constructors
SchemaSourceGenerationContext()
public SchemaSourceGenerationContext()
SchemaSourceGenerationContext(JsonSerializerOptions)
Creates an instance of JsonSerializerContext and binds it with the indicated JsonSerializerOptions.
public SchemaSourceGenerationContext(JsonSerializerOptions options)
Parameters
optionsJsonSerializerOptionsThe run time provided options for the context instance.
Properties
Boolean
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<bool> Boolean { get; }
Property Value
Default
The default JsonSerializerContext associated with a default JsonSerializerOptions instance.
public static SchemaSourceGenerationContext Default { get; }
Property Value
DictionaryStringSchema
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<Dictionary<string, Schema>> DictionaryStringSchema { get; }
Property Value
Double
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<double> Double { get; }
Property Value
GeneratedSerializerOptions
The source-generated options associated with this context.
protected override JsonSerializerOptions? GeneratedSerializerOptions { get; }
Property Value
Int32
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<int> Int32 { get; }
Property Value
Int64
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<long> Int64 { get; }
Property Value
JsonNode
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<JsonNode> JsonNode { get; }
Property Value
ListSchema
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<List<Schema>> ListSchema { get; }
Property Value
ListString
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<List<string>> ListString { get; }
Property Value
NullableBoolean
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<bool?> NullableBoolean { get; }
Property Value
NullableDouble
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<double?> NullableDouble { get; }
Property Value
NullableInt32
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<int?> NullableInt32 { get; }
Property Value
NullableInt64
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<long?> NullableInt64 { get; }
Property Value
Schema
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<Schema> Schema { get; }
Property Value
String
Defines the source generated JSON serialization contract metadata for a given type.
public JsonTypeInfo<string> String { get; }
Property Value
Methods
GetTypeInfo(Type)
Gets metadata for the specified type.
public override JsonTypeInfo? GetTypeInfo(Type type)
Parameters
typeTypeThe type to fetch metadata for.
Returns
- JsonTypeInfo
The metadata for the specified type, or null if the context has no metadata for the type.