Desenvi.StandardLibrary
1.0.0
dotnet add package Desenvi.StandardLibrary --version 1.0.0
NuGet\Install-Package Desenvi.StandardLibrary -Version 1.0.0
<PackageReference Include="Desenvi.StandardLibrary" Version="1.0.0" />
paket add Desenvi.StandardLibrary --version 1.0.0
#r "nuget: Desenvi.StandardLibrary, 1.0.0"
// 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 | Versions 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. |
-
net8.0
- Amethyst (>= 1.0.0)
- Microsoft.EntityFrameworkCore (>= 8.0.4)
- MongoDB.Driver (>= 2.25.0)
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 | 130 | 4/18/2024 |