Пример #1
0
        public Expression Adapt(LoopExpression loop)
        {
            loop = loop.InsertAssignment(Constants.BeforeLoopExitCheck, _targetElementKey, _targetMemberKey);

            var loopBody = (BlockExpression)loop.Body;

            var loopVariables = new List <ParameterExpression>(loopBody.Variables);

            if (_elementKeyExists != null)
            {
                loopVariables.Add(_elementKeyExists);

                if (PerformElementChecks && !MapperData.IsRoot)
                {
                    loopVariables.Add(_dictionaryVariables.Key);
                }
            }

            if (loopVariables.Count == loopBody.Variables.Count)
            {
                return(loop);
            }

            loopBody = loopBody.Update(loopVariables, loopBody.Expressions);

            loop = loop.Update(loop.BreakLabel, loop.ContinueLabel, loopBody);

            return(loop);
        }
        public Expression Adapt(LoopExpression loop)
        {
            loop = loop
                   .InsertAssignment(Constants.BeforeLoopExitCheck, _dictionaryVariables.Key, _targetElementKey)
                   .InsertAssignment(Constants.BeforeLoopExitCheck, _targetElementKey, _targetMemberKey);

            var loopBody = (BlockExpression)loop.Body;

            IList <ParameterExpression> loopVariables = loopBody.Variables;

            if (_elementKeyExists != null)
            {
                loopVariables = loopVariables.Append(_elementKeyExists);
            }

            if (ReferenceEquals(loopVariables, loopBody.Variables))
            {
                return(loop);
            }

            loopBody = loopBody.Update(loopVariables, loopBody.Expressions);

            loop = loop.Update(loop.BreakLabel, loop.ContinueLabel, loopBody);

            return(loop);
        }
        public Expression Adapt(LoopExpression loop)
        {
            if (_useDirectValueAccess)
            {
                return(loop);
            }

            return(loop.InsertAssignment(
                       Constants.AfterLoopExitCheck,
                       (ParameterExpression)_sourceElement,
                       _indexedSourceAccess));
        }