AFJ.Infrastructure.Lib 1.25.1

dotnet add package AFJ.Infrastructure.Lib --version 1.25.1
                    
NuGet\Install-Package AFJ.Infrastructure.Lib -Version 1.25.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="AFJ.Infrastructure.Lib" Version="1.25.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AFJ.Infrastructure.Lib" Version="1.25.1" />
                    
Directory.Packages.props
<PackageReference Include="AFJ.Infrastructure.Lib" />
                    
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 AFJ.Infrastructure.Lib --version 1.25.1
                    
#r "nuget: AFJ.Infrastructure.Lib, 1.25.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 AFJ.Infrastructure.Lib@1.25.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=AFJ.Infrastructure.Lib&version=1.25.1
                    
Install as a Cake Addin
#tool nuget:?package=AFJ.Infrastructure.Lib&version=1.25.1
                    
Install as a Cake Tool

Introduction

AFJ.Infrastructure.Lib e uma biblioteca .NET (pacote NuGet) com handlers de infraestrutura reutilizados por varias aplicacoes: envio de email, envio de SMS, fila (Azure Storage Queue), logging (S3/Azure Blob/arquivo local) e mensagens/localizacao.

Email (Infrastructure.Lib.Mail)

EmailHandler implementa IEmailHandler e suporta dois provedores por meio do enum EmailProvider:

  • EmailProvider.SendGrid (padrao, mantem o comportamento historico da biblioteca)
  • EmailProvider.Brevo (ex-Sendinblue)

O provedor e escolhido na criacao do cliente (construtor de EmailHandler), e nao em cada chamada de metodo. Isso significa que os metodos SendEmailAsync e SendEmailWithTemplateAsync mantêm exatamente a mesma assinatura de sempre — nenhum ponto do codigo que ja usa IEmailHandler/EmailHandler precisa ser alterado. Basta ajustar como o handler e instanciado (ou como ele e registrado no seu container de DI) para trocar de provedor:

// Compatibilidade: comportamento historico, sem alterar nada nos pontos de uso
var emailHandler = new EmailHandler(); // equivalente a new EmailHandler(EmailProvider.SendGrid)
await emailHandler.SendEmailAsync(to, subject, plainText, bodyHtml, apiKey);
await emailHandler.SendEmailWithTemplateAsync(to, subject, templateId, apiKey, data);

// Trocando para o Brevo: so muda a criacao do handler
var emailHandler = new EmailHandler(EmailProvider.Brevo);
await emailHandler.SendEmailAsync(to, subject, plainText, bodyHtml, apiKey);
await emailHandler.SendEmailWithTemplateAsync(to, subject, templateId, apiKey, data);

Se o handler for registrado em um container de DI (IServiceCollection), basta parametrizar o provedor no registro (ex.: services.AddSingleton<IEmailHandler>(new EmailHandler(EmailProvider.Brevo))) sem tocar nas classes que injetam IEmailHandler.

Observacoes sobre o Brevo:

  • templateId deve ser o identificador numerico do template cadastrado no Brevo (informado como string, convertido internamente).
  • O email do remetente (from) precisa estar validado/autenticado na conta Brevo usada.
  • A integracao usa o SDK oficial da Brevo para C# (brevo_csharp, TransactionalEmailsApi/SendSmtpEmail), e nao chamadas HTTP manuais.

SMS (Infrastructure.Lib.Sms)

O Brevo tambem oferece envio de SMS transacional. SmsHandler implementa ISmsHandler e segue o mesmo principio do EmailHandler: o provedor e escolhido no construtor, nao no metodo de envio.

var smsHandler = new SmsHandler(); // equivalente a new SmsHandler(SmsProvider.Brevo), unico provedor hoje
await smsHandler.SendSmsAsync(to, message, apiKey, sender: "XCaju");

Observacoes:

  • to deve estar no formato E.164 (ex.: +5511999999999).
  • sender deve ter ate 15 caracteres alfanumericos, sem espacos, para a maioria dos paises.
  • A integracao usa o SDK oficial da Brevo para C# (brevo_csharp, TransactionalSMSApi/SendTransacSms), e nao chamadas HTTP manuais.

Testes (Infrastructure.Lib.Tests)

O projeto de testes usa xUnit e executa testes de integracao contra os ambientes reais do SendGrid e do Brevo (nenhum mock/fake e usado).

  1. Copie/edite Infrastructure.Lib.Tests/appsettings.json (ja existe, esta no .gitignore) com suas chaves reais:
{
  "SendGrid": {
    "ApiKey": "SG.xxxxx",
    "From": "no-reply@seudominio.com",
    "To": "destinatario-de-teste@seudominio.com",
    "TemplateId": "d-xxxxxxxxxxxx"
  },
  "Brevo": {
    "ApiKey": "xkeysib-xxxxx",
    "From": "no-reply@seudominio.com",
    "To": "destinatario-de-teste@seudominio.com",
    "TemplateId": "1",
    "SmsSender": "XCaju",
    "SmsTo": "+5511999999999"
  }
}
  1. Rode os testes:
dotnet test Infrastructure.Lib.sln

Qualquer teste cujas chaves nao estejam preenchidas (ou ainda estejam com o valor REPLACE_...) e ignorado automaticamente (log SKIPPED), sem falhar o build. O pipeline de CI (dotnet build) so compila o projeto de testes; a execucao dos testes (dotnet test), que envia emails/SMS reais, e feita manualmente pelo desenvolvedor.

Build and Test

dotnet restore Infrastructure.Lib.sln
dotnet build Infrastructure.Lib.sln
dotnet test Infrastructure.Lib.sln

Contribute

Abra um pull request contra a branch homolog. O CI compila a solucao inteira (biblioteca + testes) e publica o pacote NuGet a partir da branch master.

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 (1)

Showing the top 1 NuGet packages that depend on AFJ.Infrastructure.Lib:

Package Downloads
Infrastructure.DataDirect

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.25.1 57 8/16/2026
1.23.0 296 3/14/2026
1.22.0 109 3/7/2026
1.21.0 108 3/2/2026
1.18.0 109 3/2/2026
1.17.0 111 2/23/2026
1.16.0 117 2/21/2026
1.15.0 113 2/21/2026
1.14.0 108 2/21/2026
1.13.0 108 2/19/2026
1.11.0 127 1/26/2026
1.1.0 436 1/23/2026