Beispiel #1
0
 /// <summary>
 /// Callback to be executed when the reported progress changes
 /// </summary>
 /// <param name="callback">Callback to be executed with the progress [0, 100] and the message</param>
 /// <returns>
 /// The current instance for chaining additional calls
 /// </returns>
 public IPromise <T> Progress(Action <int, string> callback)
 {
     if (_status == Status.Pending)
     {
         LinkedListOps.Add(ref _callback, new Callback(callback, Condition.Progress));
     }
     return(this);
 }
Beispiel #2
0
 IPromise IPromise.Done(Action <object> callback)
 {
     if (_status == Status.Resolved)
     {
         callback.Invoke(_arg);
     }
     else
     {
         LinkedListOps.Add(ref _callback, new Callback(callback, Condition.Success));
     }
     return(this);
 }
Beispiel #3
0
 /// <summary>
 /// Callback to be executed when the promise encounters an error
 /// </summary>
 /// <param name="callback">Callback to be executed with the exception of the promise</param>
 /// <returns>The current instance for chaining additional calls</returns>
 public IPromise <T> Fail(Action <Exception> callback)
 {
     if (_status == Status.Rejected)
     {
         callback.Invoke((Exception)_arg);
     }
     else
     {
         LinkedListOps.Add(ref _callback, new Callback(callback, Condition.Failure));
     }
     return(this);
 }
Beispiel #4
0
 /// <summary>
 /// Callback to be executed when the promise completes regardless of whether an error occurred
 /// </summary>
 /// <param name="callback">Callback to be executed</param>
 /// <returns>The current instance for chaining additional calls</returns>
 public IPromise <T> Always(Action callback)
 {
     if (_status != Status.Pending)
     {
         callback.Invoke();
     }
     else
     {
         LinkedListOps.Add(ref _callback, new Callback(callback, Condition.Always));
     }
     return(this);
 }
Beispiel #5
0
 internal void QuickAddAttribute(ILinkedAnnotation attr)
 {
     LinkedListOps.Add(ref _lastAttr, attr);
 }
Beispiel #6
0
 internal void QuickAddElement(ILinkedElement elem)
 {
     _content = LinkedListOps.Add(_content as ILinkedElement, elem);
 }