Exemplo n.º 1
0
        public static void ConfigureAutoMapperForDto(this IMapperConfigurationExpression config, params Assembly[] assemblies)
        {
            var dtoTypes = GetDtoTypes(assemblies);

            var mappingTypes = dtoTypes
                               .Select(type =>
            {
                var arguments = type.BaseType.GetGenericArguments();
                return(new
                {
                    DtoType = arguments[0],
                    EntityType = arguments[1]
                });
            }).ToList();

            foreach (var mappingType in mappingTypes)
            {
                config.CreateMappingAndIgnoreUnmappedProperties(mappingType.EntityType, mappingType.DtoType);
            }
        }