//-------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // File: IProducerConsumerCollectionExtensions.cs // //-------------------------------------------------------------------------- using System; namespace System { internal class DelegateBasedObserver<T> : IObserver<T> { private Action<T> _onNext; private Action<Exception> _onError; private Action _onCompleted; internal DelegateBasedObserver(Action<T> onNext, Action<Exception> onError, Action onCompleted) { if (onNext == null) throw new ArgumentNullException("onNext"); if (onError == null) throw new ArgumentNullException("onError"); if (onCompleted == null) throw new ArgumentNullException("onCompleted"); _onNext = onNext; _onError = onError; _onCompleted = onCompleted; } public void OnCompleted() { _onCompleted(); } public void OnError(Exception error) { _onError(error); } public void OnNext(T value) { _onNext(value); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)