ResultCommander 2.2.4
dotnet add package ResultCommander --version 2.2.4
NuGet\Install-Package ResultCommander -Version 2.2.4
<PackageReference Include="ResultCommander" Version="2.2.4" />
<PackageVersion Include="ResultCommander" Version="2.2.4" />
<PackageReference Include="ResultCommander" />
paket add ResultCommander --version 2.2.4
#r "nuget: ResultCommander, 2.2.4"
#:package ResultCommander@2.2.4
#addin nuget:?package=ResultCommander&version=2.2.4
#tool nuget:?package=ResultCommander&version=2.2.4
ResultCommander
Library featuring a command handler pattern for both synchronous and asynchronous operations.
Uses a functional Result approach for failure-prone operations.
To utilize all features using Autofac is required.
Features
- Synchronous and asynchronous command handler definitions
- Definitions and base implementations of commands
- Supports decorators and adapters via Autofac's methods
Description
There are two command types - one that only returns a Result and one that returns an additional entity contained within the Result.
Every handler must return a Result struct which determines whether the operation succedeed or not, handlers may or may not return additional results contained within the Result struct - this is defined by the handled comand.
Installation
To register handlers with the DI container use the ContainerBuilder or IServiceCollection extension methods provided by the library:
builder.AddResultCommander(assembliesToScan);
To register decorators or adapters use the methods available on ResultCommanderConfiguration like so:
builder.AddResultCommander(assembliesToScan, options =>
{
options.AddDecorator<FancyDecorator, ISyncCommandHandler<SimpleCommand>();
});
You can register multiple decorators and they'll be applied in the order that you register them - read more at Autofac's docs regarding decorators and adapters.
Documentation
Documentation available at https://mikym.github.io/ResultCommander/.
Download
Example usage
<b> You should never throw exceptions from within handlers, they should be exception free - instead return appropriate error results (and catch possible exceptions).</b> Library offers a simple error catching, logging and exception to result error decorators for uses where writing try-catch blocks becomes a pain - but remember that these results will never be as informative as manually returned proper result error types.
A command without a concrete result:
public record SimpleCommand(bool IsSuccess) : ICommand;
And a synchronous handler that handles it:
public class SimpleSyncCommandHandler : ISyncCommandHandler<SimpleCommand>
{
public Result Handle(SimpleCommand command)
{
if (command.IsSuccess)
return Result.FromSuccess();
return new InvalidOperationError();
}
}
A command with a concrete result:
public record SimpleCommandWithConcreteResult(bool IsSuccess) : ICommand<int>;
And an asynchronous handler that handles it:
public SimpleAsyncCommandHandlerWithConcreteResult : IAsyncCommandHandler<SimpleCommand, int>
{
public async Task<Result<int>> Handle(SimpleCommand command)
{
if (command.IsSuccess)
return 1;
return new InvalidOperationError();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- AttributeBasedRegistration (>= 2.2.7)
- Microsoft.Extensions.Options (>= 6.0.0)
- Remora.Results (>= 7.4.1)
-
net7.0
- AttributeBasedRegistration (>= 2.2.7)
- Microsoft.Extensions.Options (>= 7.0.0)
- Remora.Results (>= 7.4.1)
-
net8.0
- AttributeBasedRegistration (>= 2.2.7)
- Microsoft.Extensions.Options (>= 8.0.0)
- Remora.Results (>= 7.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ResultCommander:
| Package | Downloads |
|---|---|
|
ResultCommander.Autofac
Library featuring a command handler pattern. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.4 | 262 | 7/23/2024 |
| 2.2.3 | 326 | 1/22/2024 |
| 2.2.2 | 305 | 11/22/2023 |
| 2.2.1 | 204 | 11/20/2023 |
| 2.2.0 | 187 | 11/20/2023 |
| 2.1.6 | 284 | 8/18/2023 |
| 2.1.5 | 279 | 8/8/2023 |
| 2.1.4 | 275 | 7/10/2023 |
| 2.1.3 | 277 | 6/25/2023 |
| 2.1.2 | 473 | 5/10/2023 |
| 2.1.1 | 321 | 4/4/2023 |
| 2.1.0 | 369 | 3/14/2023 |
| 2.0.9 | 379 | 2/21/2023 |
| 2.0.8 | 433 | 1/9/2023 |
| 2.0.7 | 400 | 1/9/2023 |
| 2.0.6 | 496 | 11/21/2022 |
| 2.0.5 | 439 | 11/21/2022 |
| 2.0.4 | 455 | 11/21/2022 |
| 2.0.3 | 473 | 11/19/2022 |
| 2.0.2 | 448 | 11/19/2022 |
| 2.0.1 | 444 | 11/19/2022 |
| 2.0.0 | 435 | 11/19/2022 |
| 1.1.17 | 539 | 9/27/2022 |
| 1.1.16 | 517 | 9/27/2022 |
| 1.1.15 | 575 | 9/26/2022 |
| 1.1.14 | 549 | 9/24/2022 |
| 1.1.13 | 520 | 9/24/2022 |
| 1.1.12 | 566 | 9/24/2022 |
| 1.1.11 | 553 | 9/24/2022 |
| 1.1.10 | 555 | 9/24/2022 |
| 1.1.9 | 551 | 9/24/2022 |
| 1.1.8 | 537 | 9/24/2022 |
| 1.1.7 | 540 | 9/24/2022 |
| 1.1.6 | 540 | 9/19/2022 |
| 1.1.5 | 558 | 9/19/2022 |
| 1.1.4 | 545 | 9/19/2022 |
| 1.1.3 | 544 | 9/19/2022 |
| 1.1.2 | 553 | 9/19/2022 |
| 1.1.0 | 560 | 9/17/2022 |
| 1.0.14 | 543 | 8/28/2022 |
| 1.0.13 | 533 | 8/24/2022 |
| 1.0.12 | 532 | 8/24/2022 |
| 1.0.11 | 529 | 8/24/2022 |
| 1.0.10 | 515 | 8/24/2022 |
| 1.0.9 | 519 | 8/24/2022 |
| 1.0.8 | 538 | 8/24/2022 |
| 1.0.7 | 540 | 8/24/2022 |
| 1.0.6 | 545 | 8/23/2022 |
| 1.0.5 | 526 | 8/23/2022 |
| 1.0.4 | 525 | 8/23/2022 |
| 1.0.3 | 521 | 8/23/2022 |
| 1.0.2 | 531 | 8/23/2022 |
| 1.0.1 | 536 | 8/22/2022 |
| 1.0.0 | 529 | 8/22/2022 |