LfrlAnvil.Requests 0.6.1

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

(root) NuGet Badge

<img src="https://raw.githubusercontent.com/CalionVarduk/LfrlAnvil/main/assets/logo-small.png" alt="logo" height="80"/> LfrlAnvil.Requests

This project contains an intermediate request dispatcher, as well as a factory of request handlers.

Documentation

Technical documentation can be found here.

Examples

Following is an example of how to define a request type, how to create a handler of such requests and how to dispatch a request:

// a class that defines a request,
// with int as the type of the request's result
public class FooRequest : IRequest<FooRequest, int>
{
    // request members
}

// a class that represents a handler of requests of FooRequest type,
// with int as the type of the request's result
public class FooRequestHandler : IRequestHandler<FooRequest, int>
{
    // request handling implementation
    public int Handle(FooRequest request)
    {
        // implementation goes here
        return result;
    }
}

// creates a new empty factory of request handlers, identified by request type,
// with registered FooRequest handler
var handlerFactory = new RequestHandlerFactory()
    .Register( () => new FooRequestHandler() );

// creates a new request dispatcher that uses the above request handler factory instance
var dispatcher = new RequestDispatcher( handlerFactory );

// creates a new FooRequest instance
var request = new FooRequest { ... };

// dispatches the request and returns the result returned by its handler
var result = dispatcher.Dispatch( request );

It's also possible to work with asynchronous requests, like so:

// a class that defines an asynchronous request,
// with int as the type of the request's result
public class AsyncFooRequest : IAsyncTaskRequest<AsyncFooRequest, int>
{
    // request's cancellation token
    public CancellationToken CancellationToken { get; init; }
    
    // other request members
}

// a class that represents a handler of requests of AsyncFooRequest type,
// with int as the type of the request's result
public class AsyncFooRequestHandler : IRequestHandler<AsyncFooRequest, Task<int>>
{
    // request handling implementation
    public Task<int> Handle(AsyncFooRequest request)
    {
        // implementation goes here
        return result;
    }
}

// creates a new empty factory of request handlers, identified by request type,
// with registered AsyncFooRequest handler
var handlerFactory = new RequestHandlerFactory()
    .Register( () => new AsyncFooRequestHandler() );

// creates a new request dispatcher that uses the above request handler factory instance
var dispatcher = new RequestDispatcher( handlerFactory );

// creates a new AsyncFooRequest instance
var cancellationTokenSource = new CancellationTokenSource();
var request = new AsyncFooRequest { CancellationToken = cancellationTokenSource.Token, ... };

// dispatches the request and returns the result returned by its handler
var result = await dispatcher.Dispatch( request );
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

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.6.1 108 5/18/2026
0.6.0 102 5/16/2026
0.5.1 107 5/18/2026
0.5.0 118 5/16/2026
0.4.0 129 3/14/2026
0.3.0 238 1/7/2025
0.2.1 223 6/16/2024
0.2.0 216 6/16/2024
0.1.1 193 5/29/2024
0.1.0 213 5/26/2024