1
0

BinaryObserver.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System.Reactive
  5. {
  6. #if NO_PERF
  7. class BinaryObserver<TLeft, TRight> : IObserver<Either<Notification<TLeft>, Notification<TRight>>>
  8. {
  9. public BinaryObserver(IObserver<TLeft> leftObserver, IObserver<TRight> rightObserver)
  10. {
  11. LeftObserver = leftObserver;
  12. RightObserver = rightObserver;
  13. }
  14. public BinaryObserver(Action<Notification<TLeft>> left, Action<Notification<TRight>> right)
  15. : this(left.ToObserver(), right.ToObserver())
  16. {
  17. }
  18. public IObserver<TLeft> LeftObserver { get; private set; }
  19. public IObserver<TRight> RightObserver { get; private set; }
  20. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnNext(Either<Notification<TLeft>, Notification<TRight>> value)
  21. {
  22. value.Switch(left => left.Accept(LeftObserver), right => right.Accept(RightObserver));
  23. }
  24. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnError(Exception exception)
  25. {
  26. }
  27. void IObserver<Either<Notification<TLeft>, Notification<TRight>>>.OnCompleted()
  28. {
  29. }
  30. }
  31. #endif
  32. }