Пример #1
0
        public static MapBuilder <TSource, TResult> MapField <TSource, TResult>(
            this MapBuilder <TSource, TResult> builder,
            string from)
        {
            var prop = new PropertyConfiguration <TSource, TResult>
            {
                SourcePropertyName = from,
                TargetPropertyName = from
            };

            builder.AddProperty(prop);
            return(builder);
        }
Пример #2
0
        public static MapBuilder <TSource, TResult> MapField <TSource, TResult>(
            this MapBuilder <TSource, TResult> builder,
            Expression <Func <TSource, object> > from,
            Expression <Func <TResult, object> > to)
        {
            var prop = new PropertyConfiguration <TSource, TResult>
            {
                SourceExpression = from,
                TargetExpression = to
            };

            builder.AddProperty(prop);
            return(builder);
        }
Пример #3
0
        public static MapBuilder <TSource, TResult> MapField <TSource, TResult, TResultProp>(
            this MapBuilder <TSource, TResult> builder,
            Expression <Func <TResult, TResultProp> > to,
            Expression <Func <TSource, TResultProp> > convert)
        {
            var prop = new PropertyConfiguration <TSource, TResult>
            {
                TargetExpression = to,
                MappingFunc      = convert
            };

            builder.AddProperty(prop);
            return(builder);
        }
Пример #4
0
        public static MapBuilder <TSource, TResult> MapField <TSource, TResult>(
            this MapBuilder <TSource, TResult> builder,
            Expression <Func <TSource, object> > from)
        {
            var property = ExpressionHelper.GetPropertyFromExpression(from);

            var propertyName = property.Name;

            var prop = new PropertyConfiguration <TSource, TResult>
            {
                SourceExpression   = from,
                TargetPropertyName = propertyName
            };

            builder.AddProperty(prop);
            return(builder);
        }