Beispiel #1
0
        private void AssignSourceVariableFrom(Expression sourceValue)
        {
            _sourceTypeHelper = new EnumerableTypeHelper(
                sourceValue.Type,
                ElementTypesAreTheSame ? _sourceElementType : sourceValue.Type.GetEnumerableElementType());

            _sourceVariable = GetSourceParameterFor(sourceValue.Type);
            var sourceVariableAssignment = Expression.Assign(_sourceVariable, sourceValue);

            _populationExpressions.Add(sourceVariableAssignment);
        }
Beispiel #2
0
        public EnumerablePopulationBuilder(ObjectMapperData omd)
        {
            _omd = omd;
            _sourceItemsSelector = new SourceItemsSelector(this);

            _sourceElementType     = omd.SourceType.GetEnumerableElementType();
            _targetTypeHelper      = new EnumerableTypeHelper(omd.TargetType, omd.TargetMember.ElementType);
            _targetElementType     = _targetTypeHelper.ElementType;
            ElementTypesAreTheSame = _sourceElementType == _targetElementType;
            ElementTypesAreSimple  = _targetElementType.IsSimple();

            _sourceElementParameter = _sourceElementType.GetOrCreateParameter();

            _populationExpressions = new List <Expression>();
        }