Tolitech.Application 1.0.0-preview.10

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

Tolitech.Application

Overview

Tolitech.Application is a modern .NET library providing essential interfaces and utilities for Clean Architecture-based applications, including Unit of Work, user context, request context, and advanced enumeration handling.

Features

  • Unit of Work Interface (IUnitOfWork): Manages operations as a single transaction, including methods for saving changes, starting, committing, and rolling back transactions, and integration with Tolitech.Results.
  • User Context (IUserContext): Provides information about the authenticated user, such as identifier, username, roles, and utility methods for identifier conversion.
  • Request Context (IRequestContext): Supplies contextual information about the request, such as client IP and User-Agent.
  • IsolationLevel Enumeration: Enum for controlling transaction isolation level, allowing specification of locking behavior.
  • Enumeration Utilities:
    • EnumItem: Structure representing an enumeration item with value, name, and description.
    • EnumExtensions: Extension methods for retrieving descriptions and localized names of enums.
    • EnumUtility: Retrieves collections of EnumItem for any enum, with localization support.
  • Clean Architecture Alignment: Promotes separation between application, domain, and infrastructure layers.
  • Extensibility: Easily integrates with custom repositories and data sources.

Characteristics

  • Designed for maintainability and scalability
  • Integrates with Tolitech.Results for standardized operation results
  • Easily testable and mockable for unit testing

Main Interfaces

IUnitOfWork

public interface IUnitOfWork : IDisposable
{
    Task<int> SaveChangesInTransactionAsync(CancellationToken cancellationToken);
    Task<int> SaveChangesAsync(CancellationToken cancellationToken);
    Task<int> SaveChangesAsync(bool publishDomainEvents, CancellationToken cancellationToken);
    Task BeginTransactionAsync(CancellationToken cancellationToken);
    Task BeginTransactionAsync(IsolationLevel isolationLevel, CancellationToken cancellationToken);
    Task CommitAsync(CancellationToken cancellationToken);
    Task RollbackAsync(CancellationToken cancellationToken);
    Task CommitOrRollbackAsync(Result result, CancellationToken cancellationToken);
}

IUserContext

public interface IUserContext
{
    bool IsAuthenticated { get; }
    string? UserIdentifier { get; }
    string? Username { get; }
    IList<string> GetRoleNames();
    T? GetUserId<T>();
}

IRequestContext

public interface IRequestContext
{
    IPAddress? RemoteIpAddress { get; }
    StringValues? UserAgent { get; }
}

IsolationLevel Enumeration

Controls transaction isolation level:

public enum IsolationLevel
{
    Unspecified = -1,
    Chaos = 16,
    ReadUncommitted = 256,
    ReadCommitted = 4096,
    RepeatableRead = 65536,
    Serializable = 1048576,
    Snapshot = 16777216,
}

Enumeration Utilities

  • EnumItem: Structure representing an enumeration item with value, name, and description.
  • EnumExtensions: Extension methods for retrieving descriptions and localized names of enums.
  • EnumUtility: Retrieves collections of EnumItem for any enum, with localization support.

Usage Example

// Retrieving metadata from an enumeration
var items = EnumUtility.GetEnumValues<IsolationLevel>();
foreach (var item in items)
{
    Console.WriteLine($"Value: {item.Value}, Name: {item.Name}, Description: {item.Description}");
}

How to Integrate

  1. Reference Tolitech.Application in your project.
  2. Implement the interfaces as needed (IUnitOfWork, IUserContext, IRequestContext).
  3. Use the enumeration utilities to display or manipulate enums in advanced scenarios.
  4. Use transaction methods to ensure consistency and atomicity.

Summary

Tolitech.Application streamlines transactional management, user/request context, and enumeration handling, enforcing separation of concerns and making it an essential building block for modern .NET applications.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 Tolitech.Application:

Package Downloads
Tolitech.Infrastructure.Persistence.EntityFrameworkCore

The Tolitech.Infrastructure.Persistence.EntityFrameworkCore repository provides a foundational implementation for the Repository pattern, Unit of Work, and Specification Query Builder using Entity Framework Core. Simplify database interaction, promote code organization, and maintenance using these widely recognized patterns.

Tolitech.Infrastructure

A comprehensive infrastructure library, providing essential services and utilities to support robust and scalable architectures.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.10 422 7/21/2025
1.0.0-preview.9 113 7/7/2025
1.0.0-preview.8 109 7/7/2025
1.0.0-preview.7 113 7/7/2025
1.0.0-preview.6 112 7/7/2025
1.0.0-preview.5 119 7/3/2025
1.0.0-preview.4 114 7/3/2025
1.0.0-preview.3 162 3/17/2025
1.0.0-preview.2 69 1/8/2025
1.0.0-preview.1 107 12/8/2024