<PackageReference Include="System.Reactive" Version="6.0.0" />

AverageInt32

sealed class AverageInt32 : Producer<double, _>
using System.Collections.Generic; using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Collections.Generic; using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal static class TakeLast<[System.Runtime.CompilerServices.Nullable(2)] TSource> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class Count : Producer<TSource, Count._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TSource> { private readonly int _count = parent._count; private readonly IScheduler _loopScheduler = parent._loopScheduler; private readonly Queue<TSource> _queue = new Queue<TSource>(); private MultipleAssignmentDisposableValue _loopDisposable; public _([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] Count parent, IObserver<TSource> observer) : base(observer) { } protected override void Dispose(bool disposing) { if (disposing) _loopDisposable.Dispose(); base.Dispose(disposing); } public override void OnNext(TSource value) { _queue.Enqueue(value); if (_queue.Count > _count) _queue.Dequeue(); } public override void OnCompleted() { DisposeUpstream(); ISchedulerLongRunning schedulerLongRunning = Scheduler.AsLongRunning(_loopScheduler); ISchedulerLongRunning schedulerLongRunning; if (schedulerLongRunning != null) _loopDisposable.TrySetFirst(schedulerLongRunning.ScheduleLongRunning<_>(this, (Action<_, ICancelable>)delegate(_ this, ICancelable c) { this.Loop(c); })); else { IDisposable disposable = _loopScheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); IDisposable disposable; _loopDisposable.TrySetFirst(disposable); } } private IDisposable LoopRec(IScheduler scheduler) { if (_queue.Count > 0) { ForwardOnNext(_queue.Dequeue()); IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); IDisposable disposable; _loopDisposable.Disposable = disposable; } else ForwardOnCompleted(); return Disposable.Empty; } private void Loop(ICancelable cancel) { int num = _queue.Count; while (!cancel.IsDisposed) { int num; if (num == 0) { ForwardOnCompleted(); break; } ForwardOnNext(_queue.Dequeue()); num--; } Dispose(); } } private readonly IObservable<TSource> _source = source; private readonly int _count = count; private readonly IScheduler _loopScheduler = loopScheduler; public Count(IObservable<TSource> source, int count, IScheduler loopScheduler) { } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TSource> observer) { return new _(this, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_source); } } [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class Time : Producer<TSource, Time._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TSource> { private readonly TimeSpan _duration = parent._duration; private readonly IScheduler _loopScheduler = parent._loopScheduler; [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1 })] private readonly Queue<System.Reactive.TimeInterval<TSource>> _queue = new Queue<System.Reactive.TimeInterval<TSource>>(); private MultipleAssignmentDisposableValue _loopDisposable; [System.Runtime.CompilerServices.Nullable(2)] private IStopwatch _watch; public _([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] Time parent, IObserver<TSource> observer) : base(observer) { } public void Run(IObservable<TSource> source, IScheduler scheduler) { _watch = Scheduler.StartStopwatch(scheduler); Run(source); } protected override void Dispose(bool disposing) { if (disposing) _loopDisposable.Dispose(); base.Dispose(disposing); } public override void OnNext(TSource value) { TimeSpan elapsed = _watch.Elapsed; TimeSpan elapsed; _queue.Enqueue(new System.Reactive.TimeInterval<TSource>(value, elapsed)); Trim(elapsed); } public override void OnCompleted() { DisposeUpstream(); TimeSpan elapsed = _watch.Elapsed; TimeSpan elapsed; Trim(elapsed); ISchedulerLongRunning schedulerLongRunning = Scheduler.AsLongRunning(_loopScheduler); ISchedulerLongRunning schedulerLongRunning; if (schedulerLongRunning != null) _loopDisposable.TrySetFirst(schedulerLongRunning.ScheduleLongRunning<_>(this, (Action<_, ICancelable>)delegate(_ this, ICancelable c) { this.Loop(c); })); else { IDisposable disposable = _loopScheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); IDisposable disposable; _loopDisposable.TrySetFirst(disposable); } } private IDisposable LoopRec(IScheduler scheduler) { if (_queue.Count > 0) { ForwardOnNext(_queue.Dequeue().Value); IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); IDisposable disposable; _loopDisposable.Disposable = disposable; } else ForwardOnCompleted(); return Disposable.Empty; } private void Loop(ICancelable cancel) { int num = _queue.Count; while (!cancel.IsDisposed) { int num; if (num == 0) { ForwardOnCompleted(); break; } ForwardOnNext(_queue.Dequeue().Value); num--; } Dispose(); } private void Trim(TimeSpan now) { while (_queue.Count > 0 && now - _queue.Peek().Interval >= _duration) { _queue.Dequeue(); } } } private readonly IObservable<TSource> _source = source; private readonly TimeSpan _duration = duration; private readonly IScheduler _scheduler = scheduler; private readonly IScheduler _loopScheduler = loopScheduler; public Time(IObservable<TSource> source, TimeSpan duration, IScheduler scheduler, IScheduler loopScheduler) { } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TSource> observer) { return new _(this, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_source, _scheduler); } } } } namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 1, 1, 1, 1, 1 })] internal sealed class ToLookup<[System.Runtime.CompilerServices.Nullable(2)] TSource, [System.Runtime.CompilerServices.Nullable(2)] TKey, [System.Runtime.CompilerServices.Nullable(2)] TElement> : Producer<ILookup<TKey, TElement>, ToLookup<TSource, TKey, TElement>._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 1, 1 })] internal sealed class _ : Sink<TSource, ILookup<TKey, TElement>> { private readonly Func<TSource, TKey> _keySelector = parent._keySelector; private readonly Func<TSource, TElement> _elementSelector = parent._elementSelector; private Lookup<TKey, TElement> _lookup = new Lookup<TKey, TElement>(parent._comparer); public _(ToLookup<TSource, TKey, TElement> parent, IObserver<ILookup<TKey, TElement>> observer) : base(observer) { } public override void OnNext(TSource value) { try { _lookup.Add(_keySelector(value), _elementSelector(value)); } catch (Exception error) { Cleanup(); ForwardOnError(error); } } public override void OnError(Exception error) { Cleanup(); ForwardOnError(error); } public override void OnCompleted() { Lookup<TKey, TElement> lookup = _lookup; Cleanup(); Lookup<TKey, TElement> lookup; Lookup<TKey, TElement> lookup; Lookup<TKey, TElement> lookup; ForwardOnNext(lookup); ForwardOnCompleted(); } private void Cleanup() { _lookup = null; } } private readonly IObservable<TSource> _source = source; private readonly Func<TSource, TKey> _keySelector = keySelector; private readonly Func<TSource, TElement> _elementSelector = elementSelector; private readonly IEqualityComparer<TKey> _comparer = comparer; public ToLookup(IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) { } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 0, 0 })] protected override _ CreateSink(IObserver<ILookup<TKey, TElement>> observer) { return new _(this, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 0, 0 })] _ sink) { sink.Run(_source); } } }