FlexMapper.DependencyInjection 1.0.1

dotnet add package FlexMapper.DependencyInjection --version 1.0.1
                    
NuGet\Install-Package FlexMapper.DependencyInjection -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlexMapper.DependencyInjection" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlexMapper.DependencyInjection" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="FlexMapper.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlexMapper.DependencyInjection --version 1.0.1
                    
#r "nuget: FlexMapper.DependencyInjection, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FlexMapper.DependencyInjection@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlexMapper.DependencyInjection&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=FlexMapper.DependencyInjection&version=1.0.1
                    
Install as a Cake Tool

FlexMapper

FlexMapper e uma biblioteca leve de mapeamento de objetos para .NET 8.

Ela mapeia objetos por convencao e permite configurar mapeamento reverso, membros customizados, membros ignorados, listas, arrays, objetos aninhados e conversores de tipo.

Estrutura

src/
  FlexMapper/                    Biblioteca principal
  FlexMapper.DependencyInjection/ Integracao com ASP.NET Core DI
samples/
  ConsoleSample/                 Exemplo simples por console
tests/
  FlexMapper.Tests/              Testes automatizados xUnit
  FlexMapper.Real/               Projetos reais para validar uso via NuGet
docs/
  getting-started.md             Guia de uso
  packaging.md                   Geracao e consumo de pacotes locais
  architecture.md                Visao da arquitetura
  roadmap.md                     Proximos passos
release/                         Saida dos pacotes NuGet gerados

Instalar

Pacote principal:

dotnet add package FlexMapper

Integracao com ASP.NET Core:

dotnet add package FlexMapper.DependencyInjection

Uso basico

var config = new MapperConfiguration();

config.Map<Produto, ProdutoDto>()
      .Reverse();

var mapper = config.Build();

var dto = mapper.To<ProdutoDto>(produto);
var domain = mapper.To<Produto>(dto);

ASP.NET Core

builder.Services.AddFlexMapper(cfg =>
{
    cfg.Map<Produto, ProdutoDto>()
       .Reverse();
});

Membro customizado

cfg.Map<Pessoa, PessoaDto>()
   .For(dest => dest.Nome, src => src.NomeCompleto)
   .Reverse();

Ignorar membro

cfg.Map<Usuario, UsuarioDto>()
   .Ignore(dest => dest.SenhaHash);

Conversor customizado

cfg.AddConverter<string, bool>(value =>
{
    if (string.IsNullOrWhiteSpace(value))
        return false;

    return value.Equals("SIM", StringComparison.OrdinalIgnoreCase)
        || value.Equals("S", StringComparison.OrdinalIgnoreCase)
        || value.Equals("TRUE", StringComparison.OrdinalIgnoreCase)
        || value.Equals("1");
});

Datas

FlexMapper converte strings para DateTime e DateOnly usando InvariantCulture, a cultura atual e pt-BR.

Exemplo aceito:

Cadastro = "20/06/2026 14:20:38"

Build e testes

build.cmd

Ou manualmente:

dotnet restore FlexMapper.slnx
dotnet build FlexMapper.slnx --configuration Release
dotnet test tests/FlexMapper.Tests/FlexMapper.Tests.csproj --configuration Release

Gerar pacotes

pack.cmd

Os pacotes sao gerados em:

release/

O projeto real em tests/FlexMapper.Real possui um nuget.config apontando para essa pasta.

Recursos

  • Mapeamento por convencao
  • Mapeamento reverso
  • Mapeamento de membro customizado
  • Membros ignorados
  • Listas e arrays
  • Nullable
  • Enum
  • Guid
  • DateTime
  • DateOnly
  • TimeOnly
  • Objetos aninhados
  • Conversores customizados
  • Integracao com ASP.NET Core dependency injection
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 48 7/1/2026