Omnia.InterfaceUtility
1.0.1
dotnet add package Omnia.InterfaceUtility --version 1.0.1
NuGet\Install-Package Omnia.InterfaceUtility -Version 1.0.1
<PackageReference Include="Omnia.InterfaceUtility" Version="1.0.1" />
<PackageVersion Include="Omnia.InterfaceUtility" Version="1.0.1" />
<PackageReference Include="Omnia.InterfaceUtility" />
paket add Omnia.InterfaceUtility --version 1.0.1
#r "nuget: Omnia.InterfaceUtility, 1.0.1"
#:package Omnia.InterfaceUtility@1.0.1
#addin nuget:?package=Omnia.InterfaceUtility&version=1.0.1
#tool nuget:?package=Omnia.InterfaceUtility&version=1.0.1
Omnia.InterfaceUtility
Libreria di interfacce e utility per il framework Omnia, che fornisce contratti standardizzati per Controller, Service, Repository e componenti di paginazione.
Funzionalità
🎯 Interfacce Standard
- IGenericController - Contratto base per controller CRUD
- IGenericService - Interfaccia per servizi generici
- IGenericRepository - Pattern repository standardizzato
- File Controller Interfaces - Contratti per gestione file
📊 Paginazione
- IPagination - Interfacce per paginazione avanzata
- Query DTOs - Contratti per query complesse
- Filtering e Sorting - Interfacce per filtri e ordinamento
🔧 Service Repository Pattern
- Service Interfaces - Contratti per layer di servizio
- Repository Interfaces - Contratti per layer di persistenza
- Unit of Work - Pattern per transazioni
📁 File Management
- IFileController - Interfaccia per controller file
- File Operations - Contratti per operazioni sui file
- Upload/Download - Interfacce standardizzate
Installazione
dotnet add package Omnia.InterfaceUtility
Utilizzo
Implementazione Repository
using Omnia.InterfaceUtility;
public class ProductRepository : IGenericRepository<Product>
{
public async Task<Product> GetByIdAsync(int id)
{
// Implementazione
}
public async Task<IEnumerable<Product>> GetAllAsync()
{
// Implementazione
}
// Altri metodi CRUD...
}
Implementazione Service
public class ProductService : IGenericService<Product>
{
private readonly IGenericRepository<Product> _repository;
public ProductService(IGenericRepository<Product> repository)
{
_repository = repository;
}
// Implementa tutti i metodi dell'interfaccia
}
Controller con Interfacce
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase, IGenericController<Product>
{
private readonly IGenericService<Product> _service;
public ProductsController(IGenericService<Product> service)
{
_service = service;
}
// Implementa tutti i metodi CRUD standard
}
Paginazione
public async Task<IPaginatedResult<Product>> GetPagedProducts(IPaginationRequest request)
{
return await _service.GetPagedAsync(request);
}
Interfacce Principali
IGenericRepository<T>
public interface IGenericRepository<T> where T : class
{
Task<T> GetByIdAsync(int id);
Task<IEnumerable<T>> GetAllAsync();
Task<T> AddAsync(T entity);
Task<T> UpdateAsync(T entity);
Task<bool> DeleteAsync(int id);
Task<IPaginatedResult<T>> GetPagedAsync(IPaginationRequest request);
}
IGenericService<T>
public interface IGenericService<T> where T : class
{
Task<T> GetByIdAsync(int id);
Task<IEnumerable<T>> GetAllAsync();
Task<T> CreateAsync(T entity);
Task<T> UpdateAsync(int id, T entity);
Task<bool> DeleteAsync(int id);
Task<IPaginatedResult<T>> GetPagedAsync(IPaginationRequest request);
}
IPaginationRequest
public interface IPaginationRequest
{
int Page { get; set; }
int PageSize { get; set; }
string SortBy { get; set; }
bool SortDescending { get; set; }
string Filter { get; set; }
}
Dipendenze
- Microsoft.AspNetCore.Mvc.Core - Per controller base
- Microsoft.EntityFrameworkCore - Per pattern repository con EF
Compatibilità
- .NET 8.0 o superiore
- ASP.NET Core 8.0 o superiore
- Entity Framework Core 8.0 o superiore
Vantaggi
✅ Standardizzazione - Interfacce comuni in tutto il framework
✅ Type Safety - Contratti fortemente tipizzati
✅ Testabilità - Facile mocking per unit test
✅ Riusabilità - Interfacce utilizzabili in tutti i progetti
✅ Manutenibilità - Contratti stabili e ben definiti
Esempio di Dependency Injection
// In Program.cs
builder.Services.AddScoped<IGenericRepository<Product>, ProductRepository>();
builder.Services.AddScoped<IGenericService<Product>, ProductService>();
// In Controller
public class ProductsController : ControllerBase
{
private readonly IGenericService<Product> _service;
public ProductsController(IGenericService<Product> service)
{
_service = service;
}
}
Contribuire
- Implementa le interfacce nei tuoi progetti
- Suggerisci nuove interfacce standard
- Migliora la documentazione
- Crea esempi di utilizzo
Licenza
LGPL-3.0-or-later
Autore
Luca Gualandi - Framework Omnia
| 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. 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. |
-
net8.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.EntityFrameworkCore (>= 8.0.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Omnia.InterfaceUtility:
| Package | Downloads |
|---|---|
|
Omnia.Utility
Libreria di utility comuni per il framework Omnia - include autenticazione JWT, gestione file, paginazione e pattern repository/service |
|
|
Omnia.GenericImplementationEF
Implementazioni generiche per Entity Framework Core nel framework Omnia - Repository, AutoMapper, PredicateUtility e pattern avanzati |
GitHub repositories
This package is not used by any popular GitHub repositories.