Repeat.Until - TODO: Next Release

Dec 15, 2011 at 9:44 PM

Hi

I've known about this project for all of an hour and it looks like an excellent product! Sadly I've come across a problem. I can see in the code that Repeat.Until was commented out and "Put back for next release".

Is the next release coming any time soon?

Thanks


Dec 16, 2011 at 4:53 PM
Edited Dec 16, 2011 at 5:02 PM

I've made my own changes to the source code to enable Until.

Repeat.cs:

        private Func<bool> _becomesTrue;

//....

        internal override T Execute<T>(T current)
        {
            var method = Invoker as MethodInvoker<T>;
            
            if (null == method)
            {
                return current;
            }

            if (_becomesTrue != null)
            {
                while (!_becomesTrue.Invoke())
                {
                    current = method.Execute(current);
                    if (null != IntervalImp)
                    {
                        IntervalImp.Execute(current);
                    }
                }
            }
            else
            {
                for (int i = 0; i < Count; i++)
                {
                    current = method.Execute(current);
                    if (null != IntervalImp)
                    {
                        IntervalImp.Execute(current);
                    }
                }
            }
            return current;
        }

//....

        public IExpression Until(Func<bool> becomesTrue)
        {
            _becomesTrue = becomesTrue;
            return this;
        }

All unit tests are passing, however I had to modify the WhenUsingRepeatUntil Scenario to:

        [Scenario]
        public void Given()
        {
            _result = string.Empty;
            _workflow = Workflow<string>.Definition()
                .Do(x => _result += "AB");
        }

Anyone see a problem with this?

Coordinator
Sep 5, 2012 at 9:18 PM

There was a problem with the current implementation that I foresaw so I'll review this again. I'm looking at this for the next release (in a few weeks).