예제 #1
0
        /// <summary>
        /// 自动映射
        /// </summary>
        /// <typeparam name="To">目标对象</typeparam>
        /// <typeparam name="From">来源对象</typeparam>
        /// <param name="from">来源对象</param>
        /// <param name="target">目标对象,请实例化该对象</param>
        /// <param name="callBack">当完成映射后的回调</param>
        /// <param name="context">上下文</param>
        /// <returns></returns>
        internal static To Map <From, To>(From from, To target, Action <From, To> callBack, MapperContext context)
        {
            var action = MapperBuilder <From, To> .ActionBuild(context.Setting);

            action(from, context, target);
            callBack?.Invoke(from, target);
            return(target);
        }
예제 #2
0
        /// <summary>
        /// 自动映射
        /// </summary>
        /// <typeparam name="To">目标对象</typeparam>
        /// <typeparam name="From">来源对象</typeparam>
        /// <param name="from">来源对象</param>
        /// <param name="callBack">当完成映射后的回调</param>
        /// <param name="context">上下文</param>
        /// <returns></returns>
        internal static To Map <From, To>(From from, Action <From, To> callBack, MapperContext context)
        {
            var func = MapperBuilder <From, To> .FuncBuild(context.Setting);

            var to = func(from, context);

            callBack?.Invoke(from, to);
            return(to);
        }
예제 #3
0
        /// <summary>
        /// 自动映射
        /// </summary>
        /// <typeparam name="To">目标对象</typeparam>
        /// <typeparam name="From">来源对象</typeparam>
        /// <param name="from">来源对象</param>
        /// <param name="target">目标对象,请实例化该对象</param>
        /// <param name="callBack">当完成映射后的回调</param>
        /// <param name="setting">配置项目</param>
        /// <returns></returns>
        internal static To Map <From, To>(From from, To target, Action <From, To> callBack, MapperSetting setting)
        {
            var action = MapperBuilder <From, To> .ActionBuild(setting);

            action(from, new MapperContext()
            {
                Setting = setting
            }, target);
            callBack?.Invoke(from, target);
            return(target);
        }
예제 #4
0
        /// <summary>
        /// 自动映射
        /// </summary>
        /// <typeparam name="To">目标对象</typeparam>
        /// <typeparam name="From">来源对象</typeparam>
        /// <param name="from">来源对象</param>
        /// <param name="callBack">当完成映射后的回调</param>
        /// <param name="setting">配置项目</param>
        /// <returns></returns>
        internal static To Map <From, To>(From from, Action <From, To> callBack, MapperSetting setting)
        {
            var func = MapperBuilder <From, To> .FuncBuild(setting);

            var to = func(from, new MapperContext()
            {
                Setting = setting
            });

            callBack?.Invoke(from, to);
            return(to);
        }