示例#1
0
 public MergedIterator(IEnumerator <T>[] iterators, IComparer <T> comparator)
     : this(iterators.Length, comparator)
 {
     foreach (IEnumerator <T> iterator in iterators)
     {
         IteratorNode ctx = new IteratorNode(iterator);
         if (ctx.Fetch())
         {
             _queue.Add(ctx);              // NOTE: This was InsertWithOverflow in codeplex version
         }
     }
 }
示例#2
0
 public bool MoveNext()
 {
     if (_queue.Size() > 0)
     {
         IteratorNode ctx = (IteratorNode)_queue.Top();
         T            val = ctx._curVal;
         if (ctx.Fetch())
         {
             _queue.UpdateTop();
         }
         else
         {
             _queue.Pop();
         }
         this._current = val;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
 public bool MoveNext()
 {
     if (m_queue.Count > 0)
     {
         IteratorNode ctx = (IteratorNode)m_queue.Top;
         T            val = ctx.m_curVal;
         if (ctx.Fetch())
         {
             m_queue.UpdateTop();
         }
         else
         {
             m_queue.Pop();
         }
         this.m_current = val;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#4
0
        async Task <IInstanceNode> BuildNode(ScriptLanguage?language, NodeData node, Guid?nodeid = null)
        {
            nodeid ??= Guid.NewGuid();

            IInstanceNode instance;

            switch (node.Type)
            {
            case NodeType.Start:
                instance = new StartNode(nodeid.Value, node.Name, node.Parameters.Deserialize <StartParameters>(), compiler);
                break;

            case NodeType.Expression:
                ExecuteExpressionParameters parameters = node.Parameters.Deserialize <ExecuteExpressionParameters>();
                instance = new ExpressionNode(nodeid.Value, node.Name, await compiler.CompileCodeAsync(parameters.Code, parameters.Language));
                break;

            case NodeType.Script:
                instance = new ScriptNode(nodeid.Value, node.Name, node.Parameters.Deserialize <CallWorkableParameters>(), compiler, language);
                break;

            case NodeType.Workflow:
                instance = new WorkflowInstanceNode(nodeid.Value, node.Name, node.Parameters.Deserialize <CallWorkableParameters>(), compiler, language);
                break;

            case NodeType.BinaryOperation:
                BinaryOpParameters binparameters = node.Parameters.Deserialize <BinaryOpParameters>();
                instance = new BinaryNode(nodeid.Value, node.Name, binparameters, compiler);
                break;

            case NodeType.Value:
                ValueParameters valueparameters = node.Parameters.Deserialize <ValueParameters>();
                instance = new ValueNode(nodeid.Value, node.Name, valueparameters.Value, compiler);
                break;

            case NodeType.Suspend:
                instance = new SuspendNode(nodeid.Value, node.Name, node.Parameters.Deserialize <SuspendParameters>());
                break;

            case NodeType.Call:
                instance = new CallNode(nodeid.Value, node.Name, node.Parameters.Deserialize <CallParameters>(), compiler);
                break;

            case NodeType.Iterator:
                instance = new IteratorNode(nodeid.Value, node.Name, node.Parameters.Deserialize <IteratorParameters>(), compiler);
                break;

            case NodeType.Log:
                instance = new LogNode(nodeid.Value, node.Name, compiler, node.Parameters.Deserialize <LogParameters>());
                break;

            default:
                instance = new InstanceNode(nodeid.Value, node.Name);
                break;
            }

            if (!string.IsNullOrEmpty(node.Variable))
            {
                instance = new AssignStateNode(instance, node.Variable, node.VariableOperation, compiler);
            }
            return(instance);
        }