Omnia.InterfaceUtility 1.0.1

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

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

  1. Implementa le interfacce nei tuoi progetti
  2. Suggerisci nuove interfacce standard
  3. Migliora la documentazione
  4. Crea esempi di utilizzo

Licenza

LGPL-3.0-or-later

Autore

Luca Gualandi - Framework Omnia

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 (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.

Version Downloads Last Updated
1.0.1 196 10/20/2025
1.0.0 373 9/18/2025