Example #1
0
        public IStatefulChain <T> Run()
        {
            IStatefulChain <T> result = null;

            if (null != this.trans)
            {
                bool do_this = this.predicate(this.Item);
                if (do_this)
                {
                    this.action(this.Item);
                    this.Item = this.trans(this.Item);
                    result    = this;
                }
            }
            return(result);
        }
Example #2
0
        private static bool _Run()
        {
            bool result  = true;
            int  current = 0;
            int  last    = 0;
            IStatelessChain <int> statelessChain = StatelessChain <int> .Create((x) => x < 3, F.DoNothing <int>);

            while (null != statelessChain)
            {
                last = current;
                current++;
                statelessChain = statelessChain.Run(current);
            }
            result = result.And(F.equ_int(last, 2));
            int count = 0;
            IStatefulChain <int> statefulChain = StatefulChain <int> .Create((x) => x < 3, (y) => { count++; }, (v) => v + 1, 0);

            while (null != statefulChain)
            {
                statefulChain = statefulChain.Run();
            }
            result = result && (count == 3);
            return(result);
        }
Example #3
0
 public static IStatefulChain <T> Run(IStatefulChain <T> item)
 {
     return(item.Run());
 }