Desenvi.StandardLibrary 1.0.0

dotnet add package Desenvi.StandardLibrary --version 1.0.0                
NuGet\Install-Package Desenvi.StandardLibrary -Version 1.0.0                
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="Desenvi.StandardLibrary" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Desenvi.StandardLibrary --version 1.0.0                
#r "nuget: Desenvi.StandardLibrary, 1.0.0"                
#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.
// Install Desenvi.StandardLibrary as a Cake Addin
#addin nuget:?package=Desenvi.StandardLibrary&version=1.0.0

// Install Desenvi.StandardLibrary as a Cake Tool
#tool nuget:?package=Desenvi.StandardLibrary&version=1.0.0                

Desenvi Stardard Library

All standard tools used by the Desenvi developer team will be contained in this package. The tools are designed for our day-to-day use, but can be useful for other developers

Configuration Models

The Desenvi.StandardLibrary.Configuration namespace contains MailConfig and MongoConfig configuration files that are used by the email service and the MongoDB repository respectively.

Base Entities

IEntityBase

All SQL and MongoDB database models need to implement this interface and extend the EntityBase (for SQL) or MongoEntityBase (for MongoDB) class.

EntityBase and MongoEntityBase

These are utility classes that facilitate the creation of models by standardizing them. They contain an ID that is generated as a CUID by default, a UTC creation date field and a nullable edit date field.

Repositories

Repositories for EntityFramework must implement the IRepositoryBase interface and extend the EFRepository class. Both need to receive the generic parameter containing the model.

using Desenvi.StandardLibrary.Repositories;

public class UserRepository(AppDbContext context) : EFRepository<User>(context), IRepositoryBase<User>
{
	public User GetById(string id)
	{
		return Context.Users.FirstOrDefault(x => x.Id == id);
	}
}

Services

The only service in this first version is the EmailService for sending emails.

using Desenvi.StardardLibrary.Configuration;
using Desenvi.StardardLibrary.Services;

var config = new MailConfig
{
	Host = "host"
	Port = 425,
	UserName = "username",
	Password = "pass",
	FromInfo = new FromMailConfig
	{
		Name = "Teste",
		Email = "test@test.com"
	}
}

var emailService = new EmailService(config);

await emailService.CompileAsync<VerifyTemplate>("path/to/html/template.html", new VerifyTemplate("Daniel", 454545));

await emailService.SendAsync("Teste", "mytest@test.com", "My Subject");

Tools

The simplest tools are in static classes and can be easily used.

Generator Tool

using Desenvi.StardardLibrary.Tools;

var randomNumber = GeneratorTool.GenerateRange(0, 10); // Generates a number between 0 and 10
var randomVerificationNumber = GeneratorTool.GenerateCode(); // Generates a 6-digit code
var cuid = GeneratorTool.GenerateCUID(); // Generates a unique CUID identifier
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. 
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.0 126 4/18/2024