PushToPullSink<TSource, TResult>
using System.
Collections;
using System.
Collections.
Generic;
using System.
Diagnostics.
CodeAnalysis;
using System.
Reactive.
Disposables;
using System.
Runtime.
CompilerServices;
namespace System.
Reactive.
Linq.
ObservableImpl
{
internal abstract class PushToPullSink<[
System.
Runtime.
CompilerServices.
Nullable(
2)]
TSource, [
System.
Runtime.
CompilerServices.
Nullable(
2)]
TResult> :
IObserver<
TSource>,
IEnumerator<
TResult>,
IEnumerator,
IDisposable
{
private SingleAssignmentDisposableValue _upstream;
private bool _done;
public TResult Current { get; set; }
object IEnumerator.
Current {
get {
return Current;
}
}
[
System.
Runtime.
CompilerServices.
NullableContext(
1)]
public abstract void OnNext(
TSource value);
[
System.
Runtime.
CompilerServices.
NullableContext(
1)]
public abstract void OnError(
Exception error);
public abstract void OnCompleted();
[
System.
Runtime.
CompilerServices.
NullableContext(
1)]
public abstract bool TryMoveNext([
System.
Diagnostics.
CodeAnalysis.
MaybeNullWhen(
false)]
out TResult current);
public bool MoveNext()
{
if (!
_done) {
if (
TryMoveNext(
out TResult current)) {
Current =
current;
return true;
}
_done =
true;
Dispose();
}
return false;
}
public void Reset()
{
throw new NotSupportedException();
}
public void Dispose()
{
_upstream.
Dispose();
}
[
System.
Runtime.
CompilerServices.
NullableContext(
1)]
public void SetUpstream(
IDisposable d)
{
_upstream.
Disposable =
d;
}
}
}