예제 #1
0
파일: MapperManager.cs 프로젝트: yyalon/Sdf
        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();
                }
            }
        }
예제 #2
0
 public static TTarget Map <TSource, TTarget>(this TSource source)
 {
     if (!TinyMapper.BindingExists <TSource, TTarget>())
     {
         TinyMapper.Bind <TSource, TTarget>();
     }
     return(TinyMapper.Map <TTarget>(source));
 }
예제 #3
0
 private TTarget Map <TSource, TTarget>(TSource source)
 {
     if (!TinyMapper.BindingExists <TSource, TTarget>())
     {
         TinyMapper.Bind <TSource, TTarget>();
     }
     return(TinyMapper.Map <TTarget>(source));
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }