Tolitech.Application
1.0.0-preview.10
dotnet add package Tolitech.Application --version 1.0.0-preview.10
NuGet\Install-Package Tolitech.Application -Version 1.0.0-preview.10
<PackageReference Include="Tolitech.Application" Version="1.0.0-preview.10" />
<PackageVersion Include="Tolitech.Application" Version="1.0.0-preview.10" />
<PackageReference Include="Tolitech.Application" />
paket add Tolitech.Application --version 1.0.0-preview.10
#r "nuget: Tolitech.Application, 1.0.0-preview.10"
#:package Tolitech.Application@1.0.0-preview.10
#addin nuget:?package=Tolitech.Application&version=1.0.0-preview.10&prerelease
#tool nuget:?package=Tolitech.Application&version=1.0.0-preview.10&prerelease
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
- Reference Tolitech.Application in your project.
- Implement the interfaces as needed (IUnitOfWork, IUserContext, IRequestContext).
- Use the enumeration utilities to display or manipulate enums in advanced scenarios.
- 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 | Versions 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. |
-
net9.0
- Microsoft.Extensions.Primitives (>= 9.0.6)
- Tolitech.Results (>= 1.0.0-preview.4)
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 |