Table of Contents

Class SystemTextJsonConfigurationExtensions

Namespace
Quartz
Assembly
Quartz.dll

Choosing System.Text.Json as a persistent store's serializer, registering the serializers for trigger and calendar types of the application's own, and handing a scheduler the metadata for the application's own job-data and input types.

public static class SystemTextJsonConfigurationExtensions
Inheritance
SystemTextJsonConfigurationExtensions
Inherited Members

Methods

AddJsonTypeInfoResolver(IQuartzBuilder, IJsonTypeInfoResolver)

Hands the scheduler metadata for the application's own job-data value and job input types, which a trimmed or native AOT publish needs because it serializes nothing by reflection.

public static IQuartzBuilder AddJsonTypeInfoResolver(this IQuartzBuilder builder, IJsonTypeInfoResolver resolver)

Parameters

builder IQuartzBuilder

The scheduler being configured.

resolver IJsonTypeInfoResolver

A JsonSerializerContext the application generated — a partial class deriving from it with a [JsonSerializable(typeof(T))] attribute per type — or any other IJsonTypeInfoResolver. Its Default instance is what to hand in.

Returns

IQuartzBuilder

Remarks

One registration for both of the scheduler's System.Text.Json serializers: the persistent store's, which writes job data maps, and the one that writes an IJob<TInput>'s input, which every store uses, the in-memory one included. With reflection on — every untrimmed application — the resolver chain still ends in reflection and this changes nothing, so call it unconditionally.

The chain is Quartz's own contract, then the registry the serializer reads — its trigger and calendar types and anything handed to AddTypeInfoResolver(IJsonTypeInfoResolver) — then the resolvers handed in here, in the order they were added, then reflection where a publish has left any. A resolver that does not know a type returns nothing and the next one is asked.

It reaches the serializers Quartz builds: the default one, both forms of UseSystemTextJsonSerializer(IPersistentStoreBuilder, Action<SystemTextJsonSerializerRegistry>?), and the job input serializer. A serializer built by the application — UseSerializer(…) — reads whatever registry it was given, and the HTTP API reads the container's SystemTextJsonSerializerRegistry.

What belongs to one scheduler belongs to it alone: under AddQuartz("reporting", …) the resolver reaches reporting's serializers and no other scheduler's.

UseSystemTextJsonSerializer(IPersistentStoreBuilder, Action<SystemTextJsonSerializerRegistry>?)

Use System.Text.Json as data serialization strategy.

public static IPersistentStoreBuilder UseSystemTextJsonSerializer(this IPersistentStoreBuilder builder, Action<SystemTextJsonSerializerRegistry>? configure = null)

Parameters

builder IPersistentStoreBuilder

The persistent store being configured.

configure Action<SystemTextJsonSerializerRegistry>

Optional registration of serializers for custom trigger and calendar types, on the same SystemTextJsonSerializerRegistry the serializer resolves through. What the callback registers belongs to this scheduler alone — it is not shared with any other scheduler in the process.

Returns

IPersistentStoreBuilder

Remarks

Either way, the serializer also reads what the scheduler's builder was handed through AddJsonTypeInfoResolver(IQuartzBuilder, IJsonTypeInfoResolver), behind the registry's own resolvers.