internal static IPropertyMapConfiguration Create(LambdaExpression destination, LambdaExpression source)
        {
            if (destination == null || !destination.IsMemberPath())
            {
                return(null);
            }
            var reversed = new PathConfigurationExpression <TSource, TDestination>(destination);

            reversed.MapFromUntyped(source);
            return(reversed);
        }
Esempio n. 2
0
        public IPropertyMapConfiguration Reverse()
        {
            var destinationType = DestinationMember.DeclaringType;

            if (_sourceMember != null)
            {
                var reversedMemberConfiguration = new MemberConfigurationExpression <TDestination, TSource, object>(_sourceMember, destinationType);
                reversedMemberConfiguration.MapFrom(DestinationMember.Name);
                return(reversedMemberConfiguration);
            }
            if (destinationType.IsGenericTypeDefinition) // .ForMember("InnerSource", o => o.MapFrom(s => s))
            {
                return(null);
            }
            return(PathConfigurationExpression <TDestination, TSource, object> .Create(_sourceExpression, GetDestinationExpression()));
        }
        internal static IPropertyMapConfiguration Create(LambdaExpression destination, LambdaExpression source)
        {
            if (destination == null || !destination.IsMemberPath())
            {
                return(null);
            }
            var reversed = new PathConfigurationExpression <TSource, TDestination>(destination);

            if (reversed.MemberPath.Length == 1)
            {
                var reversedMemberExpression = new MemberConfigurationExpression <TSource, TDestination, object>(reversed.DestinationMember, typeof(TSource));
                reversedMemberExpression.MapFromUntyped(source);
                return(reversedMemberExpression);
            }
            reversed.MapFromUntyped(source);
            return(reversed);
        }
        public IPropertyMapConfiguration Reverse()
        {
            var newSourceExpression = MemberAccessLambda(DestinationMember);

            return(PathConfigurationExpression <TDestination, TSource, object> .Create(_sourceMember, newSourceExpression));
        }
Esempio n. 5
0
 public IPropertyMapConfiguration Reverse() =>
 PathConfigurationExpression <TDestination, TSource, object> .Create(_sourceMember, GetDestinationExpression());