Exemplo n.º 1
0
 public ILazyStatus Next(ILazyStatus status)
 {
     try
     {
         return(status.IsAccepted ? Accepted.New(predicate.Invoke(status.Object).IsTrue ? lambda.Invoke(status.Object) : status.Object) : status);
     }
     catch (Exception exception)
     {
         return(new Failed(exception));
     }
 }
Exemplo n.º 2
0
        public IMaybe <IObject> Next()
        {
            while (!Machine.Current.Context.Cancelled())
            {
                if (iterator.Next().If(out var value))
                {
                    var status = Accepted.New(value);

                    foreach (var action in actions)
                    {
                        status = action.Next(status);
                        if (status.IsSkipped)
                        {
                            break;
                        }
                        else if (status.IsEnded)
                        {
                            return(none <IObject>());
                        }
                    }

                    if (status.IsAccepted)
                    {
                        return(status.Object.Some());
                    }
                    else if (status.IsEnded)
                    {
                        return(none <IObject>());
                    }
                }
                else
                {
                    return(none <IObject>());
                }
            }

            return(none <IObject>());
        }