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

Repeat<TResult>

static class Repeat<TResult>
using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal static class Repeat<[System.Runtime.CompilerServices.Nullable(2)] TResult> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class ForeverRecursive : Producer<TResult, ForeverRecursive._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TResult> { private readonly TResult _value; private MultipleAssignmentDisposableValue _task; public _(TResult value, IObserver<TResult> observer) : base(observer) { _value = value; } public void Run(IScheduler scheduler) { IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRecInf(innerScheduler))); _task.TrySetFirst(disposable); } protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) _task.Dispose(); } private IDisposable LoopRecInf(IScheduler scheduler) { ForwardOnNext(_value); IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRecInf(innerScheduler))); _task.Disposable = disposable; return Disposable.Empty; } } private readonly TResult _value; private readonly IScheduler _scheduler; public ForeverRecursive(TResult value, IScheduler scheduler) { _value = value; _scheduler = scheduler; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TResult> observer) { return new _(_value, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_scheduler); } } [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class ForeverLongRunning : Producer<TResult, ForeverLongRunning._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TResult> { private readonly TResult _value; public _(TResult value, IObserver<TResult> observer) : base(observer) { _value = value; } public void Run(ISchedulerLongRunning longRunning) { SetUpstream(longRunning.ScheduleLongRunning<_>(this, (Action<_, ICancelable>)delegate(_ this, ICancelable c) { this.LoopInf(c); })); } private void LoopInf(ICancelable cancel) { TResult value = _value; while (!cancel.IsDisposed) { ForwardOnNext(value); } Dispose(); } } private readonly TResult _value; private readonly ISchedulerLongRunning _scheduler; public ForeverLongRunning(TResult value, ISchedulerLongRunning scheduler) { _value = value; _scheduler = scheduler; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TResult> observer) { return new _(_value, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_scheduler); } } [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class CountRecursive : Producer<TResult, CountRecursive._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TResult> { private readonly TResult _value; private int _remaining; private MultipleAssignmentDisposableValue _task; public _(TResult value, int repeatCount, IObserver<TResult> observer) : base(observer) { _value = value; _remaining = repeatCount; } public void Run(IScheduler scheduler) { IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); _task.TrySetFirst(disposable); } protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) _task.Dispose(); } private IDisposable LoopRec(IScheduler scheduler) { int num = _remaining; if (num > 0) { ForwardOnNext(_value); num = (_remaining = num - 1); } if (num == 0) ForwardOnCompleted(); else { IDisposable disposable = scheduler.Schedule<_>(this, (Func<IScheduler, _, IDisposable>)((IScheduler innerScheduler, _ this) => this.LoopRec(innerScheduler))); _task.Disposable = disposable; } return Disposable.Empty; } } private readonly TResult _value; private readonly IScheduler _scheduler; private readonly int _repeatCount; public CountRecursive(TResult value, int repeatCount, IScheduler scheduler) { _value = value; _scheduler = scheduler; _repeatCount = repeatCount; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TResult> observer) { return new _(_value, _repeatCount, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_scheduler); } } [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 0 })] internal sealed class CountLongRunning : Producer<TResult, CountLongRunning._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TResult> { private readonly TResult _value; private readonly int _remaining; public _(TResult value, int remaining, IObserver<TResult> observer) : base(observer) { _value = value; _remaining = remaining; } public void Run(ISchedulerLongRunning longRunning) { SetUpstream(longRunning.ScheduleLongRunning<_>(this, (Action<_, ICancelable>)delegate(_ this, ICancelable cancel) { this.Loop(cancel); })); } private void Loop(ICancelable cancel) { TResult value = _value; int num = _remaining; while (num > 0 && !cancel.IsDisposed) { ForwardOnNext(value); num--; } if (!cancel.IsDisposed) ForwardOnCompleted(); } } private readonly TResult _value; private readonly ISchedulerLongRunning _scheduler; private readonly int _repeatCount; public CountLongRunning(TResult value, int repeatCount, ISchedulerLongRunning scheduler) { _value = value; _scheduler = scheduler; _repeatCount = repeatCount; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TResult> observer) { return new _(_value, _repeatCount, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_scheduler); } } } }