Encapsulates value that must be defined later. Promises can used to to pass introduced declarations to templates as arguments when these declarations have not been introduced yet, resolving a chicken-or-egg situation. When objects of type IPromise are passed to a template, the template will automatically receive its resolved Value instead of the IPromise object.
Namespace: Metalama.Framework.Utilities
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public sealed class Promise<T> : IPromise<T>, IPromiseType Parameters
| Name | Description |
|---|---|
| T |
Constructors
| Name | Description |
|---|---|
| Promise() |
Properties
| Name | Description |
|---|---|
| Exception | Gets the Exception that the promise resulted in, if IsFaulted is |
| IsFaulted | Gets a value indicating whether the promise is faulted. In this case, the Exception property is set. |
| IsResolved | Gets a value indicating whether the Value setter has been successfully invoked. |
| Value | Gets or sets the deferred value. Getting the property throws an InvalidOperationException if it has not been set before. |
Methods
| Name | Description |
|---|---|
| SetException(Exception) | Sets the Exception in which the promise resulted and sets the IsFaulted property to |