kvandijk.Common
0.5.0
dotnet add package kvandijk.Common --version 0.5.0
NuGet\Install-Package kvandijk.Common -Version 0.5.0
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="kvandijk.Common" Version="0.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="kvandijk.Common" Version="0.5.0" />
<PackageReference Include="kvandijk.Common" />
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 kvandijk.Common --version 0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: kvandijk.Common, 0.5.0"
#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 kvandijk.Common@0.5.0
#: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=kvandijk.Common&version=0.5.0
#tool nuget:?package=kvandijk.Common&version=0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Package content
This package contains common functionality used across multiple projects, including:
BackgroundTasks
BackgroundTaskQueue: A thread-safe queue for managing background tasks.IBackgroundTaskQueue: An interface for the background task queue.QueuedWorker: A hosted service that processes tasks from theBackgroundTaskQueue.
Diagnostics
RequestTimingMiddleware: Middleware for measuring and logging the time taken to process HTTP requests.SkipRequestTimingAttribute: An attribute to skip request timing for specific endpoints.
Entities
BaseEntity: A base class for entities with anId,CreatedAt,UpdatedAt, andDeletedAtproperties.BlamingEntity: An extension ofBaseEntitythat includesCreatedBy,UpdatedByandDeletedByproperties for tracking user actions.
Extensions
SerilogExtensions: Provides methods to configure Serilog for logging.
Interfaces
IHashingService: An interface for hashing services.IRepository: A generic repository interface for CRUD operations.
Middleware
ExceptionLoggingMiddleware: Generic middleware for logging exceptions.RequestLoggingMiddleware: Middleware for logging HTTP requests.
Services
HashingService: A service that implementsIHashingServicefor hashing strings.
Utils
DotenvLoader: A utility for loading environment variables from a.envfile.
wwwroot
top-loading-bar.css: A CSS file for a top loading bar UI component.top-loading-bar.js: A JavaScript file for a top loading bar UI component.
How to use
Install the package using:
dotnet add package kvandijk.Common
Configure logging, exception handling and environment variables in Program.cs using
using kvandijk.Common.Logging;
using kvandijk.Common.Middleware;
...
// Load environment variables
DotenvLoader.Load();
var builder = WebApplication.CreateBuilder(args);
// Add Serilog
builder.ConfigureSerilog();
...
var app = builder.Build();
// Middleware pipeline configuration
app.UseMiddleware<ExceptionLoggingMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseMiddleware<RequestTimingMiddleware>();
...
Configure background tasks in Program.cs using
using kvandijk.Common.BackgroundTasks;
...
services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>();
services.AddHostedService<QueuedWorker>();
Example usage of the loading bar in a Razor page:
<link rel="stylesheet" href="/_content/kvandijk.Common/top-loading-bar.css" />
<script src="/_content/kvandijk.Common/top-loading-bar.js"></script>
<style>
:root {
--kvandijk-loading-bar-offset-y: var(--header-height);
--kvandijk-loading-bar-offset-x: var(--sidebar-width);
--kvandijk-loading-bar-color: var(--verdel-blue-gradient);
--kvandijk-loading-bar-height: 4px;
--kvandijk-loading-bar-z: 1001;
--kvandijk-loading-bar-transition: width 0.3s ease-out, opacity 0.2s ease-out;
}
</style>
<div id="top-loading-bar"></div>
| 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 is compatible. 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.
-
net10.0
- Azure.AI.OpenAI (>= 2.1.0)
- BCrypt.Net-Next (>= 4.0.3)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
-
net9.0
- Azure.AI.OpenAI (>= 2.1.0)
- BCrypt.Net-Next (>= 4.0.3)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.