Beispiel #1
0
        public void Reset()
        {
            foreach (ICodeBlock block in _innerBlocks)
            {
                block.Reset();
            }

            _trueBlock = null;
            State      = BlockState.New;
        }
Beispiel #2
0
        public LoopBlock(LoopType loopType, CustomListItemsContext ctx,
                         NatvisExpressionEvaluator evaluator, CodeBlockParser parser)
        {
            _loop      = loopType;
            _ctx       = ctx;
            _evaluator = evaluator;

            IList <ICodeBlock> loopBlocks = parser.Parse(loopType.CodeBlock ?? new object[0], ctx);

            _loopInstructions = new MultipleInstructionsBlock(loopBlocks);
        }
Beispiel #3
0
        public async Task <EvaluateResult> EvaluateAsync()
        {
            if (State == BlockState.Done)
            {
                return(EvaluateResult.None());
            }

            State = BlockState.InProgress;

            if (_trueBlock == null)
            {
                for (int i = 0; i < _conditionGroup.ConditionalCode.Count; i++)
                {
                    ConditionalCodeBlock branch = _conditionGroup.ConditionalCode[i];
                    if (await _evaluator.EvaluateConditionAsync(branch.Condition, _ctx.Variable,
                                                                _ctx.NatvisScope))
                    {
                        _trueBlock = _innerBlocks[i];
                        break;
                    }
                }

                if (_trueBlock == null)
                {
                    State = BlockState.Done;
                    return(EvaluateResult.None());
                }
            }

            EvaluateResult result = await _trueBlock.EvaluateAsync();

            if (_trueBlock.State == BlockState.Done)
            {
                State = BlockState.Done;
            }

            return(result);
        }