|
@@ -22,7 +22,7 @@ namespace System.Linq
|
|
|
if (onNext == null)
|
|
|
throw new ArgumentNullException(nameof(onNext));
|
|
|
|
|
|
- return DoHelper(source, onNext, _ => { }, () => { });
|
|
|
+ return DoCore(source, onNext, _ => { }, () => { });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -42,7 +42,7 @@ namespace System.Linq
|
|
|
if (onCompleted == null)
|
|
|
throw new ArgumentNullException(nameof(onCompleted));
|
|
|
|
|
|
- return DoHelper(source, onNext, _ => { }, onCompleted);
|
|
|
+ return DoCore(source, onNext, _ => { }, onCompleted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -62,7 +62,7 @@ namespace System.Linq
|
|
|
if (onError == null)
|
|
|
throw new ArgumentNullException(nameof(onError));
|
|
|
|
|
|
- return DoHelper(source, onNext, onError, () => { });
|
|
|
+ return DoCore(source, onNext, onError, () => { });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -86,7 +86,7 @@ namespace System.Linq
|
|
|
if (onCompleted == null)
|
|
|
throw new ArgumentNullException(nameof(onCompleted));
|
|
|
|
|
|
- return DoHelper(source, onNext, onError, onCompleted);
|
|
|
+ return DoCore(source, onNext, onError, onCompleted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -103,27 +103,10 @@ namespace System.Linq
|
|
|
if (observer == null)
|
|
|
throw new ArgumentNullException(nameof(observer));
|
|
|
|
|
|
- return DoHelper(source, observer.OnNext, observer.OnError, observer.OnCompleted);
|
|
|
+ return DoCore(source, observer.OnNext, observer.OnError, observer.OnCompleted);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TResult">Result sequence element type.</typeparam>
|
|
|
- /// <param name="source">Source sequence to repeat while the condition evaluates true.</param>
|
|
|
- /// <param name="condition">Loop condition.</param>
|
|
|
- /// <returns>Sequence generated by repeating the given sequence until the condition evaluates to false.</returns>
|
|
|
- public static IEnumerable<TResult> DoWhile<TResult>(this IEnumerable<TResult> source, Func<bool> condition)
|
|
|
- {
|
|
|
- if (source == null)
|
|
|
- throw new ArgumentNullException(nameof(source));
|
|
|
- if (condition == null)
|
|
|
- throw new ArgumentNullException(nameof(condition));
|
|
|
-
|
|
|
- return source.Concat(While(condition, source));
|
|
|
- }
|
|
|
-
|
|
|
- private static IEnumerable<TSource> DoHelper<TSource>(this IEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
|
|
|
+ private static IEnumerable<TSource> DoCore<TSource>(IEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
|
|
|
{
|
|
|
using (var e = source.GetEnumerator())
|
|
|
{
|
|
@@ -144,6 +127,7 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
onNext(current);
|
|
|
+
|
|
|
yield return current;
|
|
|
}
|
|
|
|