Пример #1
0
        public async Task <EvaluateResult> EvaluateAsync()
        {
            if (State == BlockState.Done)
            {
                return(EvaluateResult.None());
            }

            State = BlockState.InProgress;

            if (_loopInstructions.State == BlockState.Done)
            {
                _loopInstructions.Reset();
            }

            if (_loopInstructions.State == BlockState.New &&
                !await _evaluator.EvaluateConditionAsync(_loop.Condition, _ctx.Variable,
                                                         _ctx.NatvisScope))
            {
                State = BlockState.Done;
                return(EvaluateResult.None());
            }

            EvaluateResult result = await _loopInstructions.EvaluateAsync();

            if (result.Type == ResultType.Break)
            {
                State = BlockState.Done;
                return(EvaluateResult.None());
            }

            return(result);
        }
Пример #2
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);
        }