Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable/IgnoreElements.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 #if !NO_PERF
4 using System;
5
6 namespace System.Reactive.Linq.ObservableImpl
7 {
8 class IgnoreElements<TSource> : Producer<TSource>
9 {
10 private readonly IObservable<TSource> _source;
11
12 public IgnoreElements(IObservable<TSource> source)
13 {
14 _source = source;
15 }
16
17 public IObservable<TSource> Omega()
18 {
19 return this;
20 }
21
22 protected override IDisposable Run(IObserver<TSource> observer, IDisposable cancel, Action<IDisposable> setSink)
23 {
24 var sink = new _(observer, cancel);
25 setSink(sink);
26 return _source.SubscribeSafe(sink);
27 }
28
29 class _ : Sink<TSource>, IObserver<TSource>
30 {
31 public _(IObserver<TSource> observer, IDisposable cancel)
32 : base(observer, cancel)
33 {
34 }
35
36 public void OnNext(TSource value)
37 {
38 }
39
40 public void OnError(Exception error)
41 {
42 base._observer.OnError(error);
43 base.Dispose();
44 }
45
46 public void OnCompleted()
47 {
48 base._observer.OnCompleted();
49 base.Dispose();
50 }
51 }
52 }
53 }
54 #endif