Table of Contents

Class DataMapExtensions

Namespace
Quartz
Assembly
Quartz.dll

The typed read accessors for JobDataMap and SchedulerContext.

public static class DataMapExtensions
Inheritance
DataMapExtensions
Inherited Members

Remarks

A value can be stored either as its own type or — under StoreJobDataAsStrings = true, where the job store keeps everything as strings — as an invariant-culture string. Each accessor accepts both: the stored type is matched first, a string is parsed with InvariantCulture, and only an exotic stored type falls back to Convert semantics.

There is one accessor per type only for the handful of types job data is usually made of — the set twenty years of Quartz tutorials teach: int, long, float, double, bool, string and the DateTimeOffset Quartz's own times are. Everything else is Get<T> / TryGet<T> / GetValueOrDefault<T>, which coerce exactly as a named accessor would: Get<Guid> reads what a GetGuid would have read, and so do Get<TimeSpan>, Get<decimal>, Get<DateOnly> and Get<SomeEnum>. A named accessor per readable type is a set that only ever grows, and the generic one is not a weaker substitute for it.

The accessors are declared for the two concrete types rather than for IReadOnlyDictionary<string, object?> on purpose: an interface receiver would graft them onto every string-keyed dictionary in any file with using Quartz;. Both blocks are one-line bridges into a shared coercion core taking the looked-up value.

SchedulerContext gets the read accessors only, and that asymmetry with JobDataMap is deliberate. The PutAsString writers are instance members of JobDataMap because writing to a job's map is not just storing a value: the map records that it was changed, which is what tells the scheduler to persist it after a [PersistJobDataAfterExecution] job runs, and its equality is part of deciding whether anything moved. An extension cannot participate in that, and a context has nothing for it to participate in — the context is process state that no store writes back.