Class PromiseBase<T>
Promise base properties/methods.
Implements
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public abstract class PromiseBase<T> : Future<T>, IPromise where T : class
Type Parameters
Name | Description |
---|---|
T | The type of the result. |
Constructors
PromiseBase()
Initializes a new instance of the PromiseBase<T> class.
Declaration
public PromiseBase()
Properties
Id
Gets the identifier of this promise.
Declaration
public string Id { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
All<R>(Future<R>[])
Returns a promise that resolves when all passed in promises resolve.
Declaration
public static Future<R> All<R>(Future<R>[] promises)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Future<R>[] | promises | The promises to check. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
CastAndResolve(Object)
Casts the result and resolves the promise. Will throw an exception if the cast fails.
Declaration
public bool CastAndResolve(object result)
Parameters
Type | Name | Description |
---|---|---|
System.Object | result | The result. |
Returns
Type | Description |
---|---|
System.Boolean |
DoAll<R>(Future<R>[], AtomicInteger)
Internal DoAll.
Declaration
protected void DoAll<R>(Future<R>[] promises, AtomicInteger counter)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Future<R>[] | promises | |
AtomicInteger | counter |
Type Parameters
Name | Description |
---|---|
R |
Process(IPromise, Action1<T>, Action1<Exception>)
Processes the specified promise.
Declaration
protected void Process(IPromise promise, Action1<T> resolve, Action1<Exception> reject)
Parameters
Type | Name | Description |
---|---|---|
IPromise | promise | The promise. |
Action1<T> | resolve | The resolve. |
Action1<System.Exception> | reject | The reject. |
Reject(Exception)
Rejects the promise.
Declaration
public bool Reject(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | exception | The exception. |
Returns
Type | Description |
---|---|
System.Boolean |
RejectAsync(Exception)
Rejects the promise asynchronously.
Declaration
public Future<object> RejectAsync(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | exception | The exception. |
Returns
Type | Description |
---|---|
Future<System.Object> |
RejectNow(Exception)
Creates a promise and rejects it immediately.
Declaration
public static Future<object> RejectNow(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | ex | The exception. |
Returns
Type | Description |
---|---|
Future<System.Object> |
RejectNow<R>(Exception)
Creates a promise and rejects it immediately.
Declaration
public static Future<R> RejectNow<R>(Exception ex)
where R : class
Parameters
Type | Name | Description |
---|---|---|
System.Exception | ex | The exception. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
Resolve(T)
Resolves the promise.
Declaration
public bool Resolve(T result)
Parameters
Type | Name | Description |
---|---|---|
T | result | The result. |
Returns
Type | Description |
---|---|
System.Boolean |
ResolveAsync(T)
Resolves the promise asynchronously.
Declaration
public Future<object> ResolveAsync(T result)
Parameters
Type | Name | Description |
---|---|---|
T | result | The result. |
Returns
Type | Description |
---|---|
Future<System.Object> |
ResolveNow()
Creates a promise and resolves it immediately using a null result value.
Declaration
public static Future<object> ResolveNow()
Returns
Type | Description |
---|---|
Future<System.Object> |
ResolveNow<R>(R)
Creates a promise and resolves it immediately using the given result value.
Declaration
public static Future<R> ResolveNow<R>(R result)
where R : class
Parameters
Type | Name | Description |
---|---|---|
R | result | The result. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
WrapPromise<R>(Function0<Future<R>>)
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
Declaration
public static Future<R> WrapPromise<R>(Function0<Future<R>> callback)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Function0<Future<R>> | callback | The callback function. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |