public static IPromise <IPromiseEnumerator <T> > DefaultIfEmpty <T>(IPromiseEnumerator <T> items, T defaultValue)
        {
            return(items.MoveNext().Then(result =>
            {
                if (result == null)
                {
                    return PromiseEnumerator.Create(items.Factory, new T[] { defaultValue });
                }

                return items.Factory.Value(items);
            }));
        }
示例#2
0
        public static IPromise <IPromiseEnumerator <T> > Reverse <T>(IPromiseEnumerator <T> items)
        {
            return(items.MoveNext().Then(result =>
            {
                if (result == null)
                {
                    return null;
                }

                return PromiseEnumerator.Create(items.Factory, new T[] { result.Current }).Then(right =>
                {
                    return Reverse(result).Then(left =>
                    {
                        return (IPromiseEnumerator <T>)(ConcatEnumerator.Create(left, right));
                    });
                });
            }));
        }