Table of Contents

Class SchedulerContext

Namespace
Quartz
Assembly
Quartz.dll

Holds context/environment data that can be made available to Jobs as they are executed.

public sealed class SchedulerContext : IDictionary<string, object?>, ICollection<KeyValuePair<string, object?>>, IReadOnlyDictionary<string, object?>, IReadOnlyCollection<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>, IEnumerable
Inheritance
SchedulerContext
Implements
Inherited Members

Remarks

The context lives for the whole scheduler: plugins write to it during initialization while jobs and listeners read from it on their own threads, so it is backed by a ConcurrentDictionary<TKey, TValue> and is safe to read and write concurrently. It is never persisted.

The typed read accessors (GetString, TryGetInt and friends) are extension members declared in DataMapExtensions.

Constructors

SchedulerContext()

Create an empty SchedulerContext.

public SchedulerContext()

SchedulerContext(IDictionary<string, object?>)

Create a SchedulerContext with the given data.

public SchedulerContext(IDictionary<string, object?> map)

Parameters

map IDictionary<string, object>

Properties

Count

Gets the number of entries contained in the context.

public int Count { get; }

Property Value

int

IsEmpty

Gets a value indicating whether this instance is empty.

public bool IsEmpty { get; }

Property Value

bool

true if this instance is empty; otherwise, false.

this[string]

Gets or sets the object with the specified key.

public object? this[string key] { get; set; }

Parameters

key string

Property Value

object

Keys

Gets a snapshot of the keys in the context.

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

Values

Gets a snapshot of the values in the context.

public ICollection<object?> Values { get; }

Property Value

ICollection<object>

Methods

Add(string, object?)

Adds an entry with the provided key and value to the context.

public void Add(string key, object? value)

Parameters

key string

The key of the entry to add.

value object

The value of the entry to add.

Exceptions

ArgumentNullException

key is null.

ArgumentException

An entry with the same key already exists in the context.

Clear()

Removes all entries from the context.

public void Clear()

ContainsKey(string)

Determines whether the context contains an entry with the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key to locate.

Returns

bool

true if the context contains an entry with the key; otherwise, false.

CopyTo(KeyValuePair<string, object?>[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex)

Parameters

array KeyValuePair<string, object>[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, object>>

An enumerator that can be used to iterate through the collection.

Remove(string)

Removes the entry with the specified key from the context.

public bool Remove(string key)

Parameters

key string

The key of the entry to remove.

Returns

bool

TryGetValue(string, out object?)

Gets the value associated with the specified key.

public bool TryGetValue(string key, out object? value)

Parameters

key string

The key whose value to get.

value object

When this method returns, contains the value associated with the specified key, if the key is found; otherwise, null.

Returns

bool

true if the SchedulerContext contains an element with the specified key; otherwise, false.

See Also