public MultipleContextValuesValueInjector(
     LambdaExpression lambda,
     MappingConfigInfo configInfo,
     RequiredValuesSet requiredValues)
     : base(lambda, configInfo)
 {
     _lambdaBody     = lambda.Body;
     _isInvocation   = lambda.IsInvocation();
     _requiredValues = requiredValues;
 }
 private MappingContextValueInjector(
     LambdaExpression lambda,
     MappingConfigInfo configInfo,
     RequiredValuesSet requiredValues,
     bool isMappingContextInvokeLambda)
 {
     _lambda = lambda;
     _isMappingContextInvokeLambda = isMappingContextInvokeLambda;
     _requiredValues   = requiredValues;
     _configInfo       = configInfo;
     _contextParameter = lambda.Parameters[0];
     _contextType      = _contextParameter.Type;
 }
            public SingleContextValueValueInjector(
                LambdaExpression lambda,
                MappingConfigInfo configInfo,
                RequiredValuesSet requiredValues)
                : base(lambda, configInfo)
            {
                _lambdaBody = lambda.Body;

                if (requiredValues.Includes(Source))
                {
                    _value = requiredValues.Source;
                    _replacementFactory = ctx => ctx.GetSourceAccess();
                    return;
                }

                if (requiredValues.Includes(Target))
                {
                    _value = requiredValues.Target;
                    _replacementFactory = ctx => ctx.GetTargetAccess();
                    return;
                }

                if (requiredValues.Includes(ElementIndex))
                {
                    _value = requiredValues.ElementIndex;
                    _replacementFactory = ctx => ctx.GetElementIndex();
                }

                if (requiredValues.Includes(CreatedObject))
                {
                    _value = requiredValues.CreatedObject;
                    _replacementFactory = ctx => ctx.GetCreatedObject();
                    return;
                }

                if (requiredValues.Includes(ElementKey))
                {
                    _value = requiredValues.ElementKey;
                    _replacementFactory = ctx => ctx.GetElementKey();
                    return;
                }

                if (requiredValues.Includes(Parent))
                {
                    _value = requiredValues.Parent;
                    _replacementFactory = ctx => ctx.GetParentAccess();
                }
            }
        public static IValueInjector Create(
            LambdaExpression lambda,
            MappingConfigInfo configInfo,
            RequiredValuesSet requiredValues)
        {
            switch (requiredValues.ValuesCount)
            {
            case 0:
                return(new NullValueInjector(lambda));

            case 1:
                return(new SingleContextValueValueInjector(lambda, configInfo, requiredValues));

            default:
                return(new MultipleContextValuesValueInjector(lambda, configInfo, requiredValues));
            }
        }
        private ParametersAccessFinder(IList <ParameterExpression> parameters)
        {
            _requiredValues = new RequiredValuesSet();

            var parameterCount = parameters.Count;

            _sourceParameter = parameters[0];

            if (parameterCount == 1)
            {
                return;
            }

            _targetParameter = parameters[1];

            if (parameterCount == 2)
            {
                return;
            }

            var thirdParameter = parameters[2];

            if (thirdParameter.Type != typeof(int?))
            {
                _createdObjectParameter = thirdParameter;
            }
            else
            {
                _elementIndexParameter = thirdParameter;
            }

            if (parameterCount == 3)
            {
                return;
            }

            _createdObjectParameter = thirdParameter;
            _elementIndexParameter  = parameters[3];
        }
 private MappingContextMemberAccessFinder(ParameterExpression contextParameter)
 {
     _contextParameter = contextParameter;
     _requiredValues   = new RequiredValuesSet();
 }