public static TDesion MapTo <TDesion>(this object value) where TDesion : class { var dtype = typeof(TDesion); var stype = value.GetType(); IMapper map; if (stype.IsGenericType && stype.Name == "List`1") { map = BTMap.InstanceMap(stype.GetGenericArguments()[0], dtype.GetGenericArguments()[0]); } else { map = BTMap.InstanceMap(stype, dtype); } return(map.Map <TDesion>(value)); }
public static void MapTo <TSource>(this TSource value, object desion, Action <IMapperConfigurationExpression> actionMapperConfigurationExpression, int type = 1) where TSource : class { var dtype = desion.GetType(); var stype = value.GetType(); IMapper map; if (stype.IsGenericType && stype.Name == "List`1") { map = BTMap.InstanceMap(stype.GetGenericArguments()[0], dtype.GetGenericArguments()[0], actionMapperConfigurationExpression, type); } else { map = BTMap.InstanceMap(stype, dtype, actionMapperConfigurationExpression, type); } map.Map(value, desion); }
public static TDesion MapTo <TDesion>(this object value, Action <IMapperConfigurationExpression> actionMapperConfigurationExpression, int type = 1) where TDesion : class { var dtype = typeof(TDesion); var stype = value.GetType(); IMapper map; if (stype.IsGenericType && stype.Name == "List`1") { map = BTMap.InstanceMap(stype.GetGenericArguments()[0], dtype.GetGenericArguments()[0], actionMapperConfigurationExpression, type); } else { map = BTMap.InstanceMap(stype, dtype, actionMapperConfigurationExpression, type); } //var map = BTMap.InstanceMap(stype, dtype, actionMapperConfigurationExpression,type); return(map.Map <TDesion>(value)); }
/// <summary> /// 绑定规则 /// </summary> /// <param name="actionMapperConfigurationExpression"></param> /// <returns></returns> internal static IMapper InstanceMap(Type sourceType, Type destinationType, Action <IMapperConfigurationExpression> actionMapperConfigurationExpression, int type = 1) { BTMap bt = new BTMap(); return(bt.GetMap(sourceType, destinationType, actionMapperConfigurationExpression, type)); }
/// <summary> /// 使用默认配置规则 /// </summary> /// <returns></returns> internal static IMapper InstanceMap(Type sourceType, Type destinationType) { BTMap bt = new BTMap(); return(bt.GetMap(sourceType, destinationType)); }