using System; using System.Collections.Generic; using System.Linq; using System.Text; using AutoMapper; using AutoMapper.Mappers; namespace Bowin.Common.Mapping { public static class MappingExtensions { public static T CloneTo(this T obj, T newObj) { Mapper.CreateMap(); Mapper.DynamicMap(obj, newObj); return newObj; } public static void DynamicCloneTo(this TSource source, TDestination destination) { Mapper.DynamicMap(source,destination); } public static T To(this IEnumerable objects) where T : IList, new() { if (objects == null) return default(T); var tResult = new T(); foreach (var s in objects) tResult.Add(s); return tResult; } } }