Hasim 0.1.2
See the version list below for details.
dotnet add package Hasim --version 0.1.2
NuGet\Install-Package Hasim -Version 0.1.2
<PackageReference Include="Hasim" Version="0.1.2" />
<PackageVersion Include="Hasim" Version="0.1.2" />
<PackageReference Include="Hasim" />
paket add Hasim --version 0.1.2
#r "nuget: Hasim, 0.1.2"
#:package Hasim@0.1.2
#addin nuget:?package=Hasim&version=0.1.2
#tool nuget:?package=Hasim&version=0.1.2
Hasim
A lightweight .NET 8 foundation for ASP.NET Core applications, providing reusable base types and common abstractions for modern .NET apps.
Built to sit alongside the Hasim.* ecosystem (Hasim.Core, Hasim.EntityFrameworkCore, Hasim.Auditify, Hasim.Injectify), this library ships a dispose-pattern base type (IDisposable + IAsyncDisposable) and a current-user abstraction that reads the authenticated ClaimsPrincipal from IHttpContextAccessor — small, focused building blocks for your web app.
✨ Features
- Disposable base type —
Disposableimplements the standard dispose pattern with a finalizer,GC.SuppressFinalize, and virtual synchronous (DisposeCore) / asynchronous (DisposeAsyncCore) hooks. - Current-user abstraction —
ICurrentUser/CurrentUserresolve the authenticated user's id, name, email and authentication state without touchingHttpContextdirectly. - Packaged as a NuGet library — drop it into any ASP.NET Core app.
📦 Installation
dotnet add package Hasim
🚀 Getting Started
1. Register the services
Register IHttpContextAccessor and the current-user services with your DI container (e.g. in Program.cs):
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<ICurrentUser, CurrentUser>();
2. Use the current user
Inject ICurrentUser into your components or services and inspect the authenticated principal:
using Hasim.Services;
public class MyComponent(ICurrentUser user)
{
public string? DisplayName => user.UserName;
public string? Email => user.Email;
public int? Id => user.AsIntegerReadId;
public bool Authenticated => user.IsAuthenticated;
}
3. Derive from Disposable
Create a disposable service by extending Hasim.Common.Disposable and overriding the dispose hooks you need:
using Hasim.Common;
public class MyService : Disposable
{
protected override void DisposeCore() => /* release unmanaged/synchronous resources */;
protected override async ValueTask DisposeAsyncCore()
{
// release async resources, then call DisposeCore() via base
await base.DisposeAsyncCore();
}
}
🧱 Architecture
Hasim/
└── Src/Hasim/
├── Common/
│ └── Disposable.cs # IDisposable + IAsyncDisposable base type
└── Services/
└── CurrentUser.cs # ICurrentUser interface + CurrentUser implementation
CurrentUser members
| Member | Description |
|---|---|
Id |
Current user's unique identifier as a Guid?, or null when absent or invalid. |
AsIntegerId |
Id as an int (0 when unavailable). |
AsIntegerReadId |
Id as an int? (null when unavailable). |
AsStringId |
Id as a string (string.Empty when unavailable). |
UserName |
Current user's display name, or null. |
Email |
Current user's email address, or null. |
IsAuthenticated |
Whether the current user is authenticated. |
📚 Dependencies
🔧 Requirements
- .NET 8.0 SDK
🤝 Contributing
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
📄 License
This project is licensed under the MIT License.
| 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.Http.Abstractions (>= 2.3.11)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Hasim:
| Package | Downloads |
|---|---|
|
Hasim.Auditify
A lightweight, pluggable audit-trail library for EF Core 8+. Automatically captures entity changes (Added/Modified/Deleted), supports sensitive data masking, soft-delete patterns, and timestamp tracking. |
|
|
Hasim.Infrastructure
Todo Description. |
GitHub repositories
This package is not used by any popular GitHub repositories.