FluentHandlers 0.0.0-alpha.0.4
This is a prerelease version of FluentHandlers.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package FluentHandlers --version 0.0.0-alpha.0.4
NuGet\Install-Package FluentHandlers -Version 0.0.0-alpha.0.4
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="FluentHandlers" Version="0.0.0-alpha.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentHandlers --version 0.0.0-alpha.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FluentHandlers, 0.0.0-alpha.0.4"
#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.
// Install FluentHandlers as a Cake Addin
#addin nuget:?package=FluentHandlers&version=0.0.0-alpha.0.4&prerelease
// Install FluentHandlers as a Cake Tool
#tool nuget:?package=FluentHandlers&version=0.0.0-alpha.0.4&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FluentHandlers
FluentHandlers is a lightweight .NET library designed to simplify and streamline the handling of queries and commands in .NET applications. It leverages FluentValidation for input validation, offering an efficient and intuitive approach to handling business logic.
Features
- Fluent Validation Integration: Seamlessly integrates with FluentValidation for input validation of queries and commands.
- Easy-to-Use: Simple and intuitive interfaces for handling various operations.
- Flexible: Supports both parameterized and parameterless handlers.
- Dependency Injection Support: Easy registration of handlers with built-in extension methods for .NET's dependency injection system.
Getting Started
To use FluentHandlers in your project, first install the package via NuGet:
dotnet add package FluentHandlers
Usage
Registering Handlers
In your .NET application, register your handlers using the provided extension method:
using FluentHandlers;
using Microsoft.Extensions.DependencyInjection;
public void ConfigureServices(IServiceCollection services)
{
// Other service configurations...
// Add FluentHandlers
services.AddFluentHandlers(new[] { Assembly.GetExecutingAssembly() });
}
Implementing a QueryHandler
public class GetUserByIdQuery
{
public string UserId { get; set; }
}
public class GetUserByIdQueryHandler : QueryHandler<GetUserByIdQuery, UserDto>
{
protected override void DefineRules()
{
RuleFor(query => query.UserId).NotEmpty();
}
protected override async Task<UserDto> HandleValidatedQuery(GetUserByIdQuery query)
{
// Logic to fetch user data
return new UserDto { /* ... */ };
}
}
Implementing a CommandHandler
public class UpdateUserCommand
{
public string UserId { get; set; }
public string Name { get; set; }
}
public class UpdateUserCommandHandler : CommandHandler<UpdateUserCommand, bool>
{
protected override void DefineRules()
{
RuleFor(command => command.UserId).NotEmpty();
RuleFor(command => command.Name).NotEmpty();
}
protected override async Task<bool> HandleValidatedCommand(UpdateUserCommand command)
{
// Logic to update user
return true;
}
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- FluentValidation (>= 11.8.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
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 |
---|---|---|
1.0.0 | 183 | 12/12/2023 |
0.0.0-alpha.0.4 | 62 | 12/12/2023 |