Esempio n. 1
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);
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="setting"></param>
 public EasyMapper(MapperSetting setting)
 {
     this.setting = setting;
 }
Esempio n. 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);
        }