Solution

References
public sealed class Solution
Maintains a set of methods and properties which are used by IDocumentObjects while computing new solution data.

Constructors

Solution

#
public Solution(Document document, SolutionId id, CancellationTokenSource source, SolutionMode mode = SolutionMode.Regular)
Create a new solution with an existing cancellation source.
document (Document)Document that owns this intance.
id (SolutionId)Solution id.
source (CancellationTokenSource)Source used for the cancellation mechanism.
mode (SolutionMode = SolutionMode.Regular)Solution mode.

Solution

#
public Solution(Document document, SolutionId id, SolutionMode mode = SolutionMode.Regular)
Create a new solution with its own cancellation source.
document (Document)Document that owns this intance.
id (SolutionId)Solution id.
mode (SolutionMode = SolutionMode.Regular)Solution mode.

Properties

Age

#
public TimeSpan Age { get; }
Gets the age of this solution. Note that a solution never stops aging, even after it completes.

ComputableCount

#
public int ComputableCount { get; }
Gets the total number of expired, cancelled or faulted objects that will be solved as part of this solution.

Document

#
public Document Document { get; }
Gets the document associated with this solution. Note that this may be a different document from the one which hosts whatever object is given this Solution instance.

Id

#
public SolutionId Id { get; }
Gets the solution identifier.

InvalidParameters

#
public int InvalidParameters { get; }
Gets the number of invalid parameters recorded in this solution.

Mode

#
public SolutionMode Mode { get; }
Gets the mode this solution is running in.

OverallProgress

#
public int OverallProgress { get; }
Gets the overall progress of the solution. This property does a fair amount of heavy lifting, so try not to call it too often, there's a good boy...

Phase

#
public SolutionPhase Phase { get; }
Gets the state this solution is currently in.

Time

#
public DateTime Time { get; }
Gets the time (in UTC coordinates) when this solution began.

Token

#
public CancellationToken Token { get; }
Gets the cancellation token associated with this solution. The IsCancelRequested property and Cancel method are the fastest way to determine/trigger cancellation state, but you can use the Token to pass to Tasks that require one.

Methods

Cancel

#
public void Cancel()
Move the solution into the Cancelled state.

Cancelled

#
public void Cancelled()
obsoleteUse Cancel() instead.

HashParameter

#
public void HashParameter(IParameter parameter)
Hash the volatile data inside a parameter and store that hash locally in this solution. Any subsequent calls to this method with the same parameter will record whether the hash has changed. This method only works when the Mode equals either SolutionMode.Validating or SolutionMode.ValidatingSafe.
parameter (IParameter)Parameter to hash.

IsParameterHashValid

#
public bool IsParameterHashValid(IParameter parameter)
Test whether the given parameter is considered valid. This method only makes sense once the solution has completed, and when the Mode equals either SolutionMode.Validating or SolutionMode.ValidatingSafe.
parameter (IParameter)

ToString

#
public override string ToString()
Get a string representation of this solution.
Object.ToString

Events

StateChanged

#
Raised whenever the Phase of this solution changes.