While<TSource>
using System.
Collections.
Generic;
using System.
Runtime.
CompilerServices;
namespace System.
Reactive.
Linq.
ObservableImpl
{
[
System.
Runtime.
CompilerServices.
NullableContext(
1)]
[
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
0,
1,
1,
1
})]
internal sealed class While<[
System.
Runtime.
CompilerServices.
Nullable(
2)]
TSource> :
Producer<
TSource,
While<
TSource>.
_>,
IConcatenatable<
TSource>
{
[
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
0,
1
})]
internal sealed class _ :
ConcatSink<
TSource>
{
public _(
IObserver<
TSource>
observer)
:
base(
observer)
{
}
}
private readonly Func<
bool>
_condition;
private readonly IObservable<
TSource>
_source;
public While(
Func<
bool>
condition,
IObservable<
TSource>
source)
{
_condition =
condition;
_source =
source;
}
[
return:
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
1,
0
})]
protected override _ CreateSink(
IObserver<
TSource>
observer)
{
return new _(
observer);
}
protected override void Run([
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
1,
0
})]
_ sink)
{
sink.
Run(
GetSources());
}
public IEnumerable<
IObservable<
TSource>>
GetSources()
{
while (
this.
_condition()) {
yield return this.
_source;
}
}
}
}