예제 #1
0
        public TDestination Map <TDestination>(object src)
        {
            if (ReflectionService.Make().Implements <IEnumerable, TDestination>())
            {
                var type = typeof(TDestination);

                var entityType = type.GenericTypeArguments[0];

                var list = new DynamicList(entityType);

                var srcEnumerable = (IEnumerable)src;

                var constructor = ReflectionService.Make().GetConstructorForType(entityType);

                foreach (var item in srcEnumerable)
                {
                    var entity = constructor.Construct();

                    MapProperties(item, entity);

                    list.Add(entity);
                }

                return(list.Cast <TDestination>());
            }

            return(MapSingleObject <TDestination>(src));
        }