Exemple #1
0
 protected void MapFunction(MemberExpression left, Expression rightExpression)
 {
     if (left.Member.DeclaringType != rightExpression.Type)
     {
         var mapComplexResult = MappingService.GetDifferentTypeMemberMappingExpression(rightExpression, left);
         CustomPropertyCache[left.Member.Name] = mapComplexResult;
     }
     else
     {
         var binaryExpression = Expression.Assign(left, rightExpression);
         CustomPropertyCache[left.Member.Name] = binaryExpression;
     }
 }
Exemple #2
0
        public void MapFunction <TMember, TNMember>(Expression <Func <TN, TNMember> > left, Func <T, TMember> right)
        {
            var memberExpression = left.Body as MemberExpression;
            Expression <Func <T, TMember> > expr = (t) => right(t);

            var parameterExpression = Expression.Parameter(typeof(T));
            var rightExpression     = Expression.Invoke(expr, parameterExpression);

            if (typeof(TNMember) != typeof(TMember))
            {
                var mapComplexResult = _mappingService.GetDifferentTypeMemberMappingExpression(rightExpression, left.Body as MemberExpression);
                _customPropertyCache[memberExpression.Member.Name]         = mapComplexResult.Item1;
                _customPropertyDestInstCache[memberExpression.Member.Name] = mapComplexResult.Item2;
            }
            else
            {
                var binaryExpression = Expression.Assign(memberExpression, rightExpression);
                _customPropertyCache.Add(memberExpression.Member.Name, binaryExpression);
                _customPropertyDestInstCache.Add(memberExpression.Member.Name, binaryExpression);
            }
        }