Table of Contents

Class JobType

Namespace
Quartz
Assembly
Quartz.dll

Store the Job Type and FullName for serialization

public sealed class JobType : IEquatable<JobType>
Inheritance
JobType
Implements
Inherited Members

Remarks

A Type converts implicitly — that construction validates the type implements IJob and cannot fail later. A string converts only explicitly (or via the constructor), because a name is unvalidated at construction: resolving it happens on first use of Type and can throw there. Two instances are equal when their FullName is equal.

Constructors

JobType(string)

Construct a Job Type specifying the Assembly Qualified NameWithout Version. There is no check on construction this type is valid.

[RequiresUnreferencedCode("Register every job type with AddJob<T>() or reference it from JobBuilder.Create<T>(); a type named only by a string in configuration or in the database is not guaranteed to survive trimming.")]
public JobType(string fullName)

Parameters

fullName string

Type full name

Exceptions

ArgumentNullException

fullName is null

JobType(Type)

Job Type declaration

public JobType(Type type)

Parameters

type Type

The Job Type

Exceptions

ArgumentException

type is not assignable from IJob

ArgumentNullException

type is null

Properties

FullName

JobType Serialized Full name

public string FullName { get; }

Property Value

string

Type

The resolved type, loaded on first read from the name this instance was built with.

public Type Type { get; }

Property Value

Type

Methods

Equals(JobType?)

Whether this and other name the same job type.

public bool Equals(JobType? other)

Parameters

other JobType

The job type to compare with.

Returns

bool

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryResolve(out Type?)

Resolves the type for a caller that can carry on without it, without throwing and without settling Type.

public bool TryResolve(out Type? resolved)

Parameters

resolved Type

Returns

bool

Remarks

A JobType built from a Type hands back that exact instance, so a caller checking a job's type gets the right answer even when the assembly is not reachable by name - from a plugin load context, say. One built from a name has to go looking, and simply has no answer when the name does not resolve.

The lookup deliberately does not go through Type: that caches its outcome for the life of this instance, so a probe made before the job's assembly is loaded would leave the type permanently unresolvable. A speculative caller must not be able to poison the real one.

Operators

operator ==(JobType?, JobType?)

Whether two job types name the same type.

public static bool operator ==(JobType? left, JobType? right)

Parameters

left JobType
right JobType

Returns

bool

explicit operator JobType(string)

Explicit on purpose: a name is accepted unvalidated, and resolving it is deferred to the first use of Type — which is where a bad name fails. The cast makes the leap of faith visible at the call site.

[RequiresUnreferencedCode("Register every job type with AddJob<T>() or reference it from JobBuilder.Create<T>(); a type named only by a string in configuration or in the database is not guaranteed to survive trimming.")]
public static explicit operator JobType(string fullName)

Parameters

fullName string

Returns

JobType

Exceptions

ArgumentNullException

fullName is null.

implicit operator JobType(Type)

The validated direction: construction from a Type checks IJob assignability and the conversion cannot fail later.

public static implicit operator JobType(Type type)

Parameters

type Type

Returns

JobType

Exceptions

ArgumentException

type does not implement IJob.

ArgumentNullException

type is null.

operator !=(JobType?, JobType?)

Whether two job types name different types.

public static bool operator !=(JobType? left, JobType? right)

Parameters

left JobType
right JobType

Returns

bool