PushToPullSink<TSource, TResult>
using System.
Collections;
using System.
Collections.
Generic;
using System.
Reactive.
Disposables;
namespace System.
Reactive.
Linq.
ObservableImpl
{
internal abstract class PushToPullSink<
TSource,
TResult> :
IObserver<
TSource>,
IEnumerator<
TResult>,
IEnumerator,
IDisposable
{
private IDisposable _upstream;
private bool _done;
public TResult Current { get; set; }
object IEnumerator.
Current {
get {
return Current;
}
}
public abstract void OnNext(
TSource value);
public abstract void OnError(
Exception error);
public abstract void OnCompleted();
public abstract bool TryMoveNext(
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()
{
Disposable.
TryDispose(
ref _upstream);
}
public void SetUpstream(
IDisposable d)
{
Disposable.
SetSingle(
ref _upstream,
d);
}
}
}
namespace System.
Reactive.
Linq.
ObservableImpl
{
}