Пример #1
0
            public Logic(Unfold <TState, TElement> stage) : base(stage.Shape)
            {
                _stage = stage;
                _state = _stage.State;

                SetHandler(_stage.Out, this);
            }
Пример #2
0
            public Logic(Unfold <TState, TElement> stage) : base(stage.Shape)
            {
                _stage = stage;
                var state = _stage.State;

                SetHandler(_stage.Out, onPull: () =>
                {
                    var t = _stage.UnfoldFunc(state);
                    if (t == null)
                    {
                        Complete(_stage.Out);
                    }
                    else
                    {
                        Push(_stage.Out, t.Item2);
                        state = t.Item1;
                    }
                });
            }