Beispiel #1
0
 protected NodeBase(NodeBase <T> nodeBase, NodeBase <T> nodeBaseParent) : this(nodeBase.Value, nodeBaseParent)
 {
     foreach (var continuationNode in nodeBase.Continuations)
     {
         var clone = (INode <T>)continuationNode.Clone();
         Continuations.Add(clone);
     }
 }
Beispiel #2
0
 public void AddContinuation(Task continuation)
 {
     if (Continuations == null)
     {
         Continuations = new WaitList(continuation);
     }
     else
     {
         Continuations.Add(continuation);
     }
 }
Beispiel #3
0
        private Task <TNewResult> ContinueWithNewResult <TNewResult>(Task <TNewResult> task)
        {
            lock (ContinuationLock)
            {
                switch (Status)
                {
                case TaskStatus.Faulted:
                case TaskStatus.Canceled:
                case TaskStatus.RanToCompletion:
                    task.Start();
                    return(task);

                default:
                    Continuations.Add(task);
                    return(task);
                }
            }
        }
Beispiel #4
0
        public bool Equals(NodeBase <T> other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            var previousEqual = Equals(Previous, other.Previous);
            var valuesEqual   = EqualityComparer <T> .Default.Equals(Value, other.Value);

            var continuationsEqual = Continuations.Zip(other.Continuations, (t, oth) => t.Equals(oth)).All(x => x);

            return(previousEqual && valuesEqual &&
                   continuationsEqual);
        }
Beispiel #5
0
 public static Continuation <T2, R> Select <T1, T2, R>(this Continuation <T1, R> cont,
                                                       Func <T1, T2> function)
 {
     return(cont.SelectMany(function.Compose(t2 => Continuations.FromArgument <T2, R>(t2))));
 }