Table of Contents

Class Resolver<T>

Namespace
MarymoorStudios.Core.Promises
Assembly
MarymoorStudios.Core.Promises.dll

A capability for resolving an eventual computation.

public sealed class Resolver<T> : AResolver

Type Parameters

T
Inheritance
Resolver<T>
Inherited Members

Remarks

A resolver is used to produce the outcome for an eventual computation being tracked by a Promise or a Promise<T>.

Producing an outcome (success or failure) is a one-way function. Once an outcome is determined it cannot be taken back or altered. Multiple observers (e.g. multiple Promise's) may share the outcome.

Constructors

Resolver()

Creates a new unresolved resolver.

public Resolver()

Resolver(Exception)

Creates a failed resolver whose outcome is ex.

public Resolver(Exception ex)

Parameters

ex Exception

The error the resolver failed with.

Resolver(T)

Creates a successfully resolved resolver whose outcome is value.

public Resolver(T value)

Parameters

value T

The successful value.

Properties

Failure

The error the resolver failed with.

public Exception Failure { get; }

Property Value

Exception

Remarks

REQUIRES: the resolver has failed.

IsFailed

True if the resolver has failed.

public bool IsFailed { get; }

Property Value

bool

IsResolved

True if the resolver is in a resolved state (either success or failure).

public override sealed bool IsResolved { get; }

Property Value

bool

IsSuccess

True if the resolver has been resolved successfully.

public bool IsSuccess { get; }

Property Value

bool

ValueType

For a Resolver<T>, returns typeof(T).

public override sealed Type ValueType { get; }

Property Value

Type

Methods

AppendOne(Turn)

Registers a turn to be scheduled when this resolver becomes resolved.

public override sealed void AppendOne(Turn turn)

Parameters

turn Turn

The turn to be scheduled.

Remarks

If this resolver is already resolved then turn will be scheduled immediately.

Break(Exception)

Permanently transition the resolver to the "failed" state with ex as the outcome.

public void Break(Exception ex)

Parameters

ex Exception

The error to use in a failed outcome.

Forward(Promise<T>)

Permanently transition the resolver to the "forwarded" state with whatever p's outcome becomes as the outcome.

public void Forward(Promise<T> p)

Parameters

p Promise<T>

The promise whose future outcome should be this resolver's outcome.

Forward(Resolver<T>)

Permanently transition the resolver to the "forwarded" state with whatever r's outcome becomes as the outcome.

public void Forward(Resolver<T> r)

Parameters

r Resolver<T>

The resolver whose future outcome should be this resolver's outcome.

GetResult()

Returns the final outcome.

public T GetResult()

Returns

T

Remarks

REQUIRES: the resolver is resolved.

If the resolver has failed then the failing error is rethrown from this method.

Resolve(T)

Permanently transition the resolver to the "success" state with value as the outcome.

public void Resolve(T value)

Parameters

value T

The value to use in a successful outcome.