示例#1
0
        /// <summary>
        /// projected a enumerable collection of items
        /// </summary>
        /// <typeparam name="TProjection">The dtop projection type</typeparam>
        /// <param name="items">the collection of entity items</param>
        /// <returns>Projected collection</returns>
        public static List <TProjection> ProjectedAsCollection <TProjection>(this IEnumerable <object> items)
            where TProjection : class, new()
        {
            var adapter = TypeAdapterFactory.CreateAdapter();

            return(adapter.Adapt <List <TProjection> >(items));
        }
示例#2
0
        /// <summary>
        /// Adapts to specific target.
        /// </summary>
        /// <typeparam name="TProjection">The type of the projection.</typeparam>
        /// <param name="item">The item.</param>
        /// <param name="target">The target.</param>
        public static void AdaptTo <TProjection>(this object item, TProjection target)
            where TProjection : class
        {
            var adapter = TypeAdapterFactory.CreateAdapter();

            adapter.Adapt <TProjection>(item, target);
        }
示例#3
0
        /// <summary>
        /// Project a type using a DTO
        /// </summary>
        /// <typeparam name="TProjection">The dto projection</typeparam>
        /// <param name="item">The item.</param>
        /// <returns>
        /// The projected type
        /// </returns>
        public static TProjection ProjectedAs <TProjection>(this object item)
            where TProjection : class, new()
        {
            var adapter = TypeAdapterFactory.CreateAdapter();

            return(adapter.Adapt <TProjection>(item));
        }
示例#4
0
        public static object GetMapTarget(this object instance, Type distinationType)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("待转换的对象不能为空");
            }

            if (distinationType == null)
            {
                throw new ArgumentNullException("转换的目标类型不能为空");
            }

            var adapter = TypeAdapterFactory.CreateAdapter();

            return(adapter.GetMapTarget(instance, instance.GetType(), distinationType));
        }
示例#5
0
        public static Type GetMapTargetType(this object type)
        {
            var adapter = TypeAdapterFactory.CreateAdapter();

            return(adapter.GetMapTarget(type.GetType()));
        }