Hasim 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Hasim --version 0.1.2
                    
NuGet\Install-Package Hasim -Version 0.1.2
                    
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="Hasim" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hasim" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Hasim" />
                    
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 Hasim --version 0.1.2
                    
#r "nuget: Hasim, 0.1.2"
                    
#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 Hasim@0.1.2
                    
#: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=Hasim&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Hasim&version=0.1.2
                    
Install as a Cake Tool

Hasim

.NET NuGet NuGet Downloads Build License: MIT

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 — Disposable implements the standard dispose pattern with a finalizer, GC.SuppressFinalize, and virtual synchronous (DisposeCore) / asynchronous (DisposeAsyncCore) hooks.
  • Current-user abstraction — ICurrentUser / CurrentUser resolve the authenticated user's id, name, email and authentication state without touching HttpContext directly.
  • 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

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request.

📄 License

This project is licensed under the MIT License.

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

Version Downloads Last Updated
0.1.3 241 8/11/2026
0.1.2 173 8/1/2026
0.1.1 104 8/1/2026
0.1.0 244 7/30/2026