Esempio n. 1
0
        public static IServiceCollection AddAutoMapperSetup <T>(this IServiceCollection services)
            where T : class, IAutoMapperConfig, new()
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddAutoMapper();

            // Registering Mappings automatically only works if the
            // Automapper Profile classes are in ASP.NET project
            AutoMapperConfigFactory <T> .Create().RegisterMappings();

            return(services);
        }
        public ClCliente Convert(Cliente source, ClCliente destination, ResolutionContext context)
        {
            if (source == null)
            {
                return(null);
            }
            destination = new ClCliente()
            {
                Cpf       = source.Cpf.Numero != 0 ? source.Cpf.Numero.ToString() : null,
                Nome      = !string.IsNullOrEmpty(source.Nome.Texto) ? source.Nome.Texto: null,
                Uf        = !string.IsNullOrEmpty(source.Estado.SiglaEstado) ? source.Estado.SiglaEstado: null,
                Cobrancas = AutoMapperConfigFactory.GetMapper().Map <List <Cobranca>, List <ClCobranca> >(source.Cobrancas)
            };

            return(destination);
        }
Esempio n. 3
0
 public AutoMapperTeste()
 {
     mapper = AutoMapperConfigFactory.GetMapper();
 }
 public Cliente Convert(ClCliente source, Cliente destination, ResolutionContext context)
 {
     if (source == null)
     {
         return(null);
     }
     destination = Cliente.NovoCliente(Cpf.Novo(source.Cpf), Nome.Novo(source.Nome), Uf.Novo(source.Uf), AutoMapperConfigFactory.GetMapper().Map <List <ClCobranca>, List <Cobranca> >(source.Cobrancas));
     return(destination);
 }