SabiatR 3.1.1

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

SabiatR

SabiatR is a lightweight and flexible library designed for request handling and processing in .NET applications. It allows for the easy separation of request senders and handlers while providing the ability to customize and extend request handling with pipeline behaviors like logging, validation, and authorization.

With SabiatR, you can structure your application to keep it clean, maintainable, and extensible. It provides a clear separation between the request sender and handler, offering full support for pipeline behaviors that can intercept requests before and after they are handled.

🚀 Features Request Handling: Simplifies sending and handling of commands and queries in your application.

This project supports the use of internal classes for:

IRequestHandler<TRequest, TResponse> command and query handlers

IPipelineBehavior<TRequest, TResponse> middleware-style behaviors

Pipeline Behaviors: Supports adding middleware-style behaviors (such as logging, validation, and authorization) to requests at various stages of processing.

Flexible and Extendable: Easily extendable to accommodate custom logic and supports both synchronous and asynchronous operations.

Dependency Injection: Integrates seamlessly with .NET's built-in Dependency Injection container.

Type Safety: Provides strong typing for requests and handlers, supporting multiple request and response types.

⚙️ How It Works SabiatR is built around the Mediator pattern, which helps separate the sender of a request from the handler that processes it. This allows for better decoupling of different parts of the application.

Request Handling: Requests (commands/queries) are sent through an ISender service. This service resolves the appropriate handler and processes the request.

Pipeline Behaviors: Before and after handling a request, you can define pipeline behaviors that can intercept and modify the request. For example, you could add behaviors for logging the request details, validating the request, or performing authorization checks before the request is processed.

Pipeline behaviors provide a way to add logic around the request handling process without directly modifying the handler code.

📦 Installation SabiatR can be installed via NuGet:

bash Copy Edit dotnet add package SabiatR 🛠️ Usage Register Services To get started, you will need to register SabiatR in your application’s service container. This is typically done in your Startup.cs or Program.cs file.

Once registered, you can easily configure your application to send requests and resolve the appropriate handlers.

Define Requests and Handlers Requests can be defined as simple command or query objects. Each request corresponds to a handler that processes the request and provides the necessary logic for it. The handler is responsible for performing the actual work for that specific request type.

Define Pipeline Behaviors Pipeline behaviors allow you to inject additional logic before or after a request is handled. You can define behaviors for purposes such as:

Logging: Track the incoming requests and their responses for debugging or monitoring.

Validation: Ensure that the request meets certain criteria before the handler processes it.

Authorization: Check if the request is authorized to be processed based on the user's permissions or other factors.

Behaviors can be added to the request pipeline in a modular way, and multiple behaviors can be chained together.

Sending Requests Requests are sent through the ISender interface, which resolves the appropriate handler for the request and executes it. You can send commands, queries, or other types of requests and receive responses, depending on the nature of the request.

Handling Multiple Behaviors SabiatR allows you to stack multiple pipeline behaviors, ensuring that each one is applied in the desired order. Each behavior can perform its logic and then pass control to the next behavior in the pipeline, or ultimately, the handler.

📚 Advanced Features Pipeline Behavior for Commands and Queries You can define specific behaviors for different types of requests (commands and queries). This gives you fine-grained control over how different requests are processed.

Extending SabiatR SabiatR is designed to be easily extendable. You can create custom request types, handlers, and behaviors, or modify the way requests are processed to suit your application's needs. The library's flexibility makes it suitable for a wide variety of use cases.

📝 Contributing We welcome contributions to SabiatR! If you have suggestions, bug fixes, or new features that would improve the library, feel free to fork the repository and submit a pull request. Contributions to the documentation are also appreciated.

📄 License SabiatR is licensed under the MIT License. See the LICENSE file for more details.

This README provides a high-level overview of the functionality and usage of SabiatR. It emphasizes the flexibility and extensibility of the library while explaining its core features, like request handling and pipeline behaviors.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.1 162 4/27/2025
3.1.0 165 4/27/2025
3.0.0 87 4/26/2025
2.0.0 118 4/25/2025
1.0.0 160 4/24/2025

Added advanced pipeline behaviors, notification, request handlers, improved DI integration, and support for .NET 8.0.