KrapkaNet.Handling.Commands 0.0.40-PR006-11

This is a prerelease version of KrapkaNet.Handling.Commands.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package KrapkaNet.Handling.Commands --version 0.0.40-PR006-11
                    
NuGet\Install-Package KrapkaNet.Handling.Commands -Version 0.0.40-PR006-11
                    
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="KrapkaNet.Handling.Commands" Version="0.0.40-PR006-11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KrapkaNet.Handling.Commands" Version="0.0.40-PR006-11" />
                    
Directory.Packages.props
<PackageReference Include="KrapkaNet.Handling.Commands" />
                    
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 KrapkaNet.Handling.Commands --version 0.0.40-PR006-11
                    
#r "nuget: KrapkaNet.Handling.Commands, 0.0.40-PR006-11"
                    
#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 KrapkaNet.Handling.Commands@0.0.40-PR006-11
                    
#: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=KrapkaNet.Handling.Commands&version=0.0.40-PR006-11&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=KrapkaNet.Handling.Commands&version=0.0.40-PR006-11&prerelease
                    
Install as a Cake Tool

KrapkaNet.Handling.Commands

A .NET Standard 2.1 library for typed command processing. Its command interfaces inherit Handle from IHandler<TContext, TResult> in KrapkaNet.Handling.Abstractions. The request ID identifies the call, and context.Input holds the command.

Use ICommandHandler<TCommand, TReceipt> when a caller needs an acceptance receipt. For example, a gateway and a worker can both implement ICommandHandler<PrintJob, PrintReceipt>. The gateway implementation submits the job and waits for the worker’s reply. The worker implementation records the job and returns its receipt. The application defines the transport, when acceptance is durable, and how printing proceeds after intake.

For a command that produces its final result on the same delivery, implement ICommandProcessor<TCommand, TResult>.

To invoke both intake and execution through a command router, register an ICommandHandler<TCommand, TState, TResult>. Each route pairs a parser with a typed handler. The application supplies the request, command, state, and result types.

var router = new CommandRouter<string, object, PrintQueue, PrintReceipt>();
router.Register("print", text => string.IsNullOrWhiteSpace(text) ? null : new PrintJob(text),
    new PrintHandler());

// On intake
var incoming = router.Bind("print", requestId, "Quarterly report");
if (incoming != null)
    await incoming.AcceptAsync(queue, cancellationToken);

// On a later delivery, use the original request ID, route and payload.
var delivery = router.Bind("print", requestId, "Quarterly report");
if (delivery != null)
    await delivery.Handle(queue, cancellationToken);

The application's PrintHandler implements ICommandHandler<PrintJob, PrintQueue, PrintReceipt>. Its AcceptAsync method records the job. On the execution delivery, Handle prints it. Both methods receive the command in context.Input, its originating context.RequestId, the queue in context.State, and the caller's cancellation token. A test can invoke execution through the shared handler interface.

IHandler<ICommandContext<PrintJob, PrintQueue>, PrintReceipt> handler = new PrintHandler();
var input = new HandlerContext<PrintJob>(requestId, new PrintJob("Quarterly report"));
var execution = new CommandContext<PrintJob, PrintQueue>(input, queue);
var receipt = await handler.Handle(execution, cancellationToken);

Route names are case-sensitive. Registering the same name twice throws ArgumentException. Binding returns null for an unknown route or when the parser returns null. The caller controls persistence, retries, and when it calls AcceptAsync and Handle. Create the router in the same scope as its handlers.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.0.40-PR006-15 76 12/4/2026
0.0.40-PR006-11 60 12/4/2026