diff Implab/PromiseExtensions.cs @ 205:8200ab154c8a v2

Added ResetState to RunnableComponent to reset in case of failure Added StateChanged event to IRunnable Renamed Promise.SUCCESS -> Promise.Success Added Promise.FromException Renamed Bundle -> PromiseAll in PromiseExtensions
author cin
date Tue, 25 Oct 2016 17:40:33 +0300
parents 822aab37b107
children 558f34b2fb50
line wrap: on
line diff
--- a/Implab/PromiseExtensions.cs	Tue Oct 18 17:49:54 2016 +0300
+++ b/Implab/PromiseExtensions.cs	Tue Oct 25 17:40:33 2016 +0300
@@ -2,7 +2,8 @@
 using System;
 using Implab.Diagnostics;
 using System.Collections.Generic;
-
+using System.Linq;
+
 namespace Implab {
     public static class PromiseExtensions {
         public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) {
@@ -75,7 +76,7 @@
             ((ICancellable)cookie).Cancel(new TimeoutException());
         }
 
-        /// <summary>
+/// <summary>
         /// Cancells promise after the specified timeout is elapsed.
         /// </summary>
         /// <param name="that">The promise to cancel on timeout.</param>
@@ -88,7 +89,17 @@
             return that;
         }
 
-        public static IPromise Bundle(this ICollection<IPromise> that) {
+        public static IPromise PromiseAll(this IEnumerable<IPromise> that) {
+            Safe.ArgumentNotNull(that, "that");
+            return PromiseAll(that.ToList());
+        }
+
+        public static IPromise<T[]> PromiseAll<T>(this IEnumerable<IPromise<T>> that) {
+            Safe.ArgumentNotNull(that, "that");
+            return PromiseAll(that.ToList());
+        }
+
+        public static IPromise PromiseAll(this ICollection<IPromise> that) {
             Safe.ArgumentNotNull(that, "that");
 
             int count = that.Count;
@@ -128,7 +139,7 @@
             return medium;
         }
 
-        public static IPromise<T[]> Bundle<T>(this ICollection<IPromise<T>> that) {
+        public static IPromise<T[]> PromiseAll<T>(this ICollection<IPromise<T>> that) {
             Safe.ArgumentNotNull(that, "that");
 
             int count = that.Count;