public static void MapperConfig <TSource, TTarget>(Action <IMapperConfig <TSource, TTarget> > config) { MapperConfig <TSource, TTarget> mapperConfig = new MapperConfig <TSource, TTarget>(); config?.Invoke(mapperConfig); if (!TinyMapper.BindingExists <TSource, TTarget>()) { if (config == null) { TinyMapper.Bind <TSource, TTarget>(); } else { TinyMapper.Bind <TSource, TTarget>(mapperConfig.CreateTinyMapperConfig()); } } if (mapperConfig.GetFilter() != null) { string filterKey = String.Format("{0}-{1}", typeof(TSource).GetHashCode(), typeof(TTarget).GetHashCode()); filterDictionary[filterKey] = mapperConfig.GetFilter(); } if (mapperConfig.ConstructUsing() != null) { string key = String.Format("{0}-{1}", typeof(TSource).GetHashCode(), typeof(TTarget).GetHashCode()); if (!constructUsingDictionary.Keys.Any(m => m == key)) { constructUsingDictionary[key] = mapperConfig.ConstructUsing(); } } }
public static TTarget Map <TSource, TTarget>(this TSource source) { if (!TinyMapper.BindingExists <TSource, TTarget>()) { TinyMapper.Bind <TSource, TTarget>(); } return(TinyMapper.Map <TTarget>(source)); }
private TTarget Map <TSource, TTarget>(TSource source) { if (!TinyMapper.BindingExists <TSource, TTarget>()) { TinyMapper.Bind <TSource, TTarget>(); } return(TinyMapper.Map <TTarget>(source)); }
public static T2 TinyMapperTools <T1, T2>(T1 origin) { if (!TinyMapper.BindingExists <T1, T2>()) { TinyMapper.Bind <T1, T2>(); } T2 Result = TinyMapper.Map <T2>(origin); return(Result); }
public static T2 TinyMapperTools <T1, T2>(T1 origin, Action <IBindingConfig <T1, T2> > config) { if (!TinyMapper.BindingExists <T1, T2>()) { TinyMapper.Bind <T1, T2>(config); } T2 Result = TinyMapper.Map <T2>(origin); return(Result); }