Exemple #1
0
            public Logic(FirstOrDefault <TIn> stage) : base(stage.Shape)
            {
                _inlet = stage._in;

                Action onPush = () =>
                {
                    _promise.TrySetResult(Grab(_inlet));
                    CompleteStage();
                };

                Action onUpstreamFinish = () =>
                {
                    if (stage._throwOnDefault)
                    {
                        _promise.TrySetException(new NoSuchElementException("First of empty stream"));
                    }
                    else
                    {
                        _promise.TrySetResult(default(TIn));
                    }

                    CompleteStage();
                };

                Action <Exception> onUpstreamFailure = e =>
                {
                    _promise.TrySetException(e);
                    FailStage(e);
                };

                SetHandler(stage._in, onPush, onUpstreamFinish, onUpstreamFailure);
            }
Exemple #2
0
            public Logic(FirstOrDefault <TIn> stage) : base(stage.Shape)
            {
                _stage = stage;

                SetHandler(stage._in, this);
            }