Materialize<TSource> sealed class Materialize<TSource> : Producer<Notification<TSource>, _<TSource>> Documentation Code namespace System.Reactive.Linq.ObservableImpl { internal sealed class Materialize<TSource> : Producer<Notification<TSource>, Materialize<TSource>._> { internal sealed class _ : Sink<Notification<TSource>>, IObserver<TSource> { public _(IObserver<Notification<TSource>> observer, IDisposable cancel) : base(observer, cancel) { } public void OnNext(TSource value) { _observer.OnNext(Notification.CreateOnNext<TSource>(value)); } public void OnError(Exception error) { _observer.OnNext(Notification.CreateOnError<TSource>(error)); _observer.OnCompleted(); base.Dispose(); } public void OnCompleted() { _observer.OnNext(Notification.CreateOnCompleted<TSource>()); _observer.OnCompleted(); base.Dispose(); } } private readonly IObservable<TSource> _source; public Materialize(IObservable<TSource> source) { _source = source; } public IObservable<TSource> Dematerialize() { return Observable.AsObservable<TSource>(_source); } protected override _ CreateSink(IObserver<Notification<TSource>> observer, IDisposable cancel) { return new _(observer, cancel); } protected override IDisposable Run(_ sink) { return ObservableExtensions.SubscribeSafe<TSource>(_source, (IObserver<TSource>)sink); } } }