BinaryObserver.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. namespace System.Reactive
  3. {
  4. #if NO_PERF
  5. class BinaryObserver<TLeft, TRight> : IObserver<Either<Notification<TLeft>, Notification<TRight>>>
  6. {
  7. public BinaryObserver(IObserver<TLeft> leftObserver, IObserver<TRight> rightObserver)
  8. {
  9. LeftObserver = leftObserver;
  10. RightObserver = rightObserver;
  11. }
  12. public BinaryObserver(Action<Notification<TLeft>> left, Action<Notification<TRight>> right)
  13. : this(left.ToObserver(), right.ToObserver())
  14. {
  15. }
  16. public IObserver<TLeft> LeftObserver { get; private set; }
  17. public IObserver<TRight> RightObserver { get; private set; }
  18. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnNext(Either<Notification<TLeft>, Notification<TRight>> value)
  19. {
  20. value.Switch(left => left.Accept(LeftObserver), right => right.Accept(RightObserver));
  21. }
  22. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnError(Exception exception)
  23. {
  24. }
  25. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnCompleted()
  26. {
  27. }
  28. }
  29. #endif
  30. }