<PackageReference Include="System.Reactive" Version="5.0.0-preview.220" />

MaxInt64

sealed class MaxInt64 : Producer<long, _>
using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class MaxInt64 : Producer<long, MaxInt64._> { [System.Runtime.CompilerServices.NullableContext(0)] internal sealed class _ : IdentitySink<long> { private bool _hasValue; private long _lastValue; [System.Runtime.CompilerServices.NullableContext(1)] public _(IObserver<long> observer) : base(observer) { } public override void OnNext(long value) { if (_hasValue) { if (value > _lastValue) _lastValue = value; } else { _lastValue = value; _hasValue = true; } } public override void OnCompleted() { if (!_hasValue) try { throw new InvalidOperationException(Strings_Linq.NO_ELEMENTS); } catch (Exception error) { ForwardOnError(error); } else { ForwardOnNext(_lastValue); ForwardOnCompleted(); } } } private readonly IObservable<long> _source; public MaxInt64(IObservable<long> source) { _source = source; } protected override _ CreateSink(IObserver<long> observer) { return new _(observer); } protected override void Run(_ sink) { sink.Run(_source); } } }