Common.Infrastructure.Lib 2.1.0

dotnet add package Common.Infrastructure.Lib --version 2.1.0
                    
NuGet\Install-Package Common.Infrastructure.Lib -Version 2.1.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="Common.Infrastructure.Lib" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Common.Infrastructure.Lib" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Common.Infrastructure.Lib" />
                    
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 Common.Infrastructure.Lib --version 2.1.0
                    
#r "nuget: Common.Infrastructure.Lib, 2.1.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 Common.Infrastructure.Lib@2.1.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=Common.Infrastructure.Lib&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Common.Infrastructure.Lib&version=2.1.0
                    
Install as a Cake Tool

Common Infrastructure Library

Overview

The Common Infrastructure Library is a shared library that provides core infrastructure components for various applications. This library includes utilities and services that simplify tasks such as messaging, resilience, request context handling, and repository patterns. It is designed to be used as a NuGet package in other projects, allowing for easy integration of common functionality across multiple services.

This library provides a foundation of reusable components, reducing the need to rewrite common code in each project. It also includes enhanced resilience features for error handling, retry policies, and messaging patterns.

Key Components

Infrastructure

The Infrastructure module contains essential components and utilities that provide foundational services required by other parts of the application.

Messaging

The Messaging module offers messaging services for communication between different components or microservices. It helps in integrating messaging patterns like event-driven architecture and message queues.

Repositories

The Repositories module defines the repository pattern to abstract data access. It simplifies interaction with data sources and allows for more maintainable and testable code.

RequestContext

The RequestContext module is responsible for managing request-specific data, ensuring that relevant context is passed throughout the lifecycle of a request.

Resilience

The Resilience module adds reliability features to the application, including retry policies and circuit breaker patterns, which are critical for fault-tolerant applications.

Constants

The Constants class provides a collection of constant values used throughout the application. These constants help ensure consistency and avoid hardcoded values in the code.

Project Structure

Folders:

  • Infrastructure: Contains core infrastructure components.
  • Messaging: Provides messaging utilities and services for communication between services.
  • Repositories: Contains data access abstractions and implementations for repositories.
  • RequestContext: Provides tools to manage the request-specific data.
  • Resilience: Implements resilience patterns, such as retries and circuit breakers.
  • Constants.cs: Defines common constants used across the application.

Key Files:

  • Common.Infrastructure.csproj: The project file that defines the dependencies and structure of the library.
  • Common.Infrastructure.sln: The solution file for building and managing the project.
  • Constants.cs: A file defining constant values used across the library.

Installation

Step 1: Add the NuGet Package

You can integrate the Common Infrastructure Library into your project by adding the NuGet package:

dotnet add package Common.Infrastructure --version <version-number>

Replace <version-number> with the desired version of the package.

Step 2: Usage

Once the library is added to your project, you can use the provided classes and utilities:

  • Messaging: For sending and receiving messages between components.
  • Resilience: For adding retry policies and circuit breakers.
  • Repositories: For implementing data access layers using the repository pattern.
  • RequestContext: For accessing and managing request-specific context.
  • Constants: For reusing common constant values across the application.

Example usage in your project:

using Common.Infrastructure.Messaging;
using Common.Infrastructure.Resilience;

public class MyService
{
    private readonly IMessageService _messageService;
    private readonly IResilienceService _resilienceService;

    public MyService(IMessageService messageService, IResilienceService resilienceService)
    {
        _messageService = messageService;
        _resilienceService = resilienceService;
    }

    public void PerformAction()
    {
        // Use resilience service for retry logic
        _resilienceService.ExecuteWithRetry(() => 
        {
            // Send message using message service
            _messageService.SendMessage("My message");
        });
    }
}

Development and Contribution

Prerequisites

Before building the library locally, make sure you have the following installed:

  • .NET SDK: Required to build the library. Download from here.

Step 1: Clone the Repository

Clone the repository to your local machine:

git clone <repository-url>
cd <repository-name>

Step 2: Build the Library

To build the library, use the following command:

dotnet build

Step 3: Run Tests

If there are unit tests included, run the tests to ensure everything works as expected:

dotnet test

Step 4: Publish to NuGet

To publish the package to NuGet, use the following command:

dotnet nuget push <package-file> --api-key <api-key> --source https://api.nuget.org/v3/index.json

Replace <package-file> with the .nupkg file and <api-key> with your NuGet API key.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Conclusion

The Common Infrastructure Library provides a set of reusable components that simplify common tasks and patterns in .NET applications. It is designed to be packaged as a NuGet library for easy integration into other projects. With components for messaging, resilience, data access, and request context management, this library helps build robust, maintainable applications.

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 (1)

Showing the top 1 NuGet packages that depend on Common.Infrastructure.Lib:

Package Downloads
Common.Keycloak.Lib

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 107 9/4/2025
2.0.106 106 9/3/2025
2.0.105 146 9/1/2025
2.0.104 174 8/29/2025
2.0.103 168 8/29/2025
2.0.102 170 8/29/2025
2.0.101 183 8/28/2025
2.0.100 176 8/27/2025
2.0.99 186 8/26/2025
2.0.98 268 8/25/2025
2.0.97 138 8/20/2025
2.0.96 139 8/20/2025
2.0.95 133 8/19/2025
2.0.94 147 8/13/2025
2.0.93 553 8/8/2025
2.0.92 489 8/8/2025
2.0.91 443 8/7/2025
2.0.90 459 8/6/2025
2.0.89 435 8/6/2025
2.0.88 445 8/5/2025
2.0.87 330 8/3/2025
2.0.86 300 8/3/2025
2.0.85 331 7/31/2025
2.0.84 330 7/31/2025
2.0.83 349 7/30/2025
2.0.82 312 7/29/2025
2.0.81 309 7/29/2025
2.0.80 312 7/28/2025
2.0.79 662 7/23/2025
2.0.78 706 7/23/2025
2.0.77 701 7/22/2025
2.0.76 669 7/21/2025
2.0.75 614 7/21/2025
2.0.74 267 7/19/2025
2.0.73 263 7/19/2025
2.0.72 294 7/18/2025
2.0.71 349 7/17/2025
2.0.70 336 7/17/2025
2.0.69 437 7/14/2025
2.0.68 500 7/8/2025
2.0.67 365 7/8/2025
2.0.66 363 7/8/2025
2.0.65 363 7/8/2025
2.0.64 364 7/8/2025
2.0.63 360 7/8/2025
2.0.62 361 7/8/2025
2.0.61 364 7/8/2025
2.0.60 463 7/8/2025
2.0.59 361 7/7/2025
2.0.58 316 7/4/2025
2.0.57 335 7/4/2025
2.0.56 358 7/3/2025
2.0.55 358 7/2/2025
2.0.54 358 7/2/2025
2.0.53 360 7/2/2025
2.0.52 360 7/1/2025
2.0.51 353 6/30/2025
2.0.50 352 6/29/2025
2.0.49 360 6/29/2025
2.0.48 356 6/25/2025
2.0.47 384 6/24/2025
2.0.46 357 6/24/2025
2.0.45 356 6/24/2025
2.0.44 357 6/24/2025
2.0.43 361 6/24/2025
2.0.42 352 6/23/2025
2.0.41 355 6/23/2025
2.0.40 362 6/23/2025
2.0.39 355 6/20/2025
2.0.38 361 6/19/2025
2.0.37 367 6/19/2025
2.0.36 366 6/18/2025
2.0.35 502 6/12/2025
2.0.34 504 6/12/2025
2.0.33 513 6/11/2025
2.0.32 518 6/10/2025
2.0.31 503 6/10/2025
2.0.30 509 6/9/2025
2.0.29 660 6/9/2025
2.0.28 450 6/9/2025
2.0.27 375 6/4/2025
2.0.26 397 6/2/2025
2.0.25 361 6/2/2025
2.0.24 376 6/2/2025
2.0.22 366 6/2/2025
2.0.21 364 6/2/2025
2.0.20 372 6/2/2025
2.0.19 415 5/29/2025
2.0.18 365 5/29/2025
2.0.17 365 5/29/2025
2.0.16 368 5/28/2025
2.0.15 362 5/28/2025
2.0.14 430 5/27/2025
2.0.13 375 5/27/2025
2.0.12 375 5/27/2025
2.0.11 372 5/26/2025
2.0.10 373 5/26/2025
2.0.9 364 5/22/2025
2.0.4 365 5/22/2025
2.0.2 362 5/20/2025
2.0.1 461 5/14/2025
1.0.102 475 5/14/2025
1.0.100 321 5/9/2025
1.0.99 371 5/8/2025
1.0.98 370 5/8/2025
1.0.97 398 5/8/2025
1.0.96 374 5/8/2025
1.0.95 384 5/8/2025
1.0.94 397 5/8/2025
1.0.93 431 5/7/2025
1.0.92 376 5/5/2025
1.0.91 359 5/5/2025
1.0.90 363 5/5/2025
1.0.89 372 5/5/2025
1.0.88 364 5/5/2025
1.0.87 367 5/5/2025
1.0.86 369 5/5/2025
1.0.85 368 5/5/2025
1.0.84 390 4/29/2025
1.0.83 381 4/28/2025
1.0.82 390 4/28/2025
1.0.81 368 4/28/2025
1.0.80 374 4/27/2025
1.0.79 326 4/27/2025
1.0.78 300 4/26/2025
1.0.77 300 4/25/2025
1.0.76 313 4/25/2025
1.0.75 387 4/25/2025
1.0.74 366 4/23/2025
1.0.73 390 4/22/2025
1.0.72 533 4/15/2025
1.0.71 431 4/15/2025
1.0.70 448 4/14/2025
1.0.69 361 4/11/2025
1.0.68 434 4/9/2025
1.0.67 417 4/9/2025
1.0.66 408 4/7/2025
1.0.65 414 4/7/2025
1.0.64 404 4/1/2025
1.0.63 367 3/27/2025
1.0.62 685 3/26/2025
1.0.61 706 3/25/2025
1.0.60 404 3/18/2025
1.0.59 387 3/17/2025
1.0.58 404 3/17/2025
1.0.57 563 3/16/2025
1.0.56 511 3/10/2025
1.0.55 525 3/10/2025
1.0.54 371 2/27/2025
1.0.53 340 2/19/2025
1.0.52 405 2/17/2025
1.0.51 334 2/17/2025
1.0.50 420 2/14/2025
1.0.49 353 2/13/2025
1.0.48 409 2/13/2025
1.0.47 336 2/13/2025
1.0.46 345 2/12/2025
1.0.45 392 2/3/2025
1.0.44 325 2/3/2025
1.0.43 443 1/18/2025
1.0.42 437 1/15/2025
1.0.41 306 1/14/2025
1.0.40 311 1/14/2025
1.0.39 350 1/2/2025
1.0.38 429 12/31/2024
1.0.37 472 12/26/2024
1.0.36 432 12/22/2024
1.0.35 602 12/9/2024
1.0.34 571 12/5/2024
1.0.33 339 12/5/2024
1.0.32 337 12/5/2024
1.0.31 518 12/5/2024
1.0.30 741 12/2/2024
1.0.29 330 12/2/2024
1.0.28 337 12/2/2024
1.0.27 339 12/2/2024
1.0.26 394 12/2/2024
1.0.25 343 11/29/2024
1.0.24 324 11/29/2024
1.0.23 357 11/28/2024
1.0.22 337 11/28/2024
1.0.21 355 11/27/2024
1.0.20 347 11/27/2024
1.0.19 393 11/26/2024
1.0.18 343 11/25/2024
1.0.17 348 11/25/2024
1.0.15 338 11/21/2024
1.0.14 349 11/21/2024
1.0.13 330 11/20/2024
1.0.12 385 11/13/2024
1.0.11 520 11/13/2024
1.0.10 347 11/8/2024
1.0.9 346 10/29/2024
1.0.8 376 10/29/2024
1.0.7 357 10/28/2024
1.0.6 394 10/25/2024
1.0.5 378 10/25/2024
1.0.4 356 10/22/2024
1.0.3 330 10/22/2024
1.0.2 326 10/22/2024
1.0.1 525 10/15/2024
1.0.0 368 10/11/2024