public IDisposable Subscribe(IObserver <int> observer) { observer.OnNext(1); observer.OnNext(2); observer.OnNext(3); observer.OnNext(4); observer.OnNext(5); return(GenericDisposable.Create(() => {})); }
protected virtual void StartRecording(RenderRenderingArgs args) { var writer = MinificationHelpers.ShouldMinify() ? new OptimizedRecordingTextWriter(args.Writer) : new RecordingTextWriter(args.Writer); var item = new GenericDisposable(delegate { writer.Flush(); }); args.Disposables.Add(item); args.Writer = writer; }
public void TestGenericDisposable() { var value = 0; using (var dispose = GenericDisposable.Create(() => value++)) { Assert.AreEqual(0, value); } Assert.AreEqual(1, value); }
public void Disposables_will_be_disposed_on_dispose() { var disposable1 = new GenericDisposable(); var disposable2 = new GenericDisposable(); try { using (var tx1 = CreateDefaultScope()) { tx1.AddDisposable(disposable1); tx1.AddDisposable(disposable2); } Assert.True(disposable1.Disposed); Assert.True(disposable2.Disposed); } finally { disposable1?.Dispose(); disposable2?.Dispose(); } }
public IDisposable TraceMethod(string message = null, [CallerMemberName] string method = "") { this.logger.LogDebug(method); return(GenericDisposable.Create(() => { this.logger.LogDebug(method); })); }
public IDisposable Subscribe(IObserver <int> observer) { _observers.Add(observer); return(GenericDisposable.Create(() => _observers.Remove(observer))); }