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
fullNamestringType full name
Exceptions
- ArgumentNullException
fullNameis null
JobType(Type)
Job Type declaration
public JobType(Type type)
Parameters
typeTypeThe Job Type
Exceptions
- ArgumentException
typeis not assignable from IJob- ArgumentNullException
typeis null
Properties
FullName
JobType Serialized Full name
public string FullName { get; }
Property Value
Type
The resolved type, loaded on first read from the name this instance was built with.
public Type Type { get; }
Property Value
Methods
Equals(JobType?)
Whether this and other name the same job type.
public bool Equals(JobType? other)
Parameters
otherJobTypeThe job type to compare with.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
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
resolvedType
Returns
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
Returns
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
fullNamestring
Returns
Exceptions
- ArgumentNullException
fullNameis 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
typeType
Returns
Exceptions
- ArgumentException
typedoes not implement IJob.- ArgumentNullException
typeis null.
operator !=(JobType?, JobType?)
Whether two job types name different types.
public static bool operator !=(JobType? left, JobType? right)