Interlink 1.0.1

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

Interlink is a lightweight and modern mediator library for .NET, designed to decouple your code through request/response and notification patterns. Built with simplicity and performance in mind, it helps streamline communication between components while maintaining a clean architecture.


✨ Features

  • 🧩 Simple mediator pattern for request/response
  • 🔄 Decouples logic using handlers
  • 🧩 Easy registration with AddInterlink()
  • 🔧 Supports dependency injection with IServiceProvider
  • 🚀 Lightweight, fast, and no external dependencies
  • ✅ Fully compatible with .NET 8, .NET 9

  • Clean, intuitive API
  • No bloat, just mediation
  • Ideal for CQRS, Clean Architecture, and modular designs

🛠️ Usage

You can install Interlink via NuGet Package Manager or .NET CLI.

dotnet add package Interlink
using Interlink;

builder.Services.AddInterlink();

2. Define a Request and Response

public class GetAllPets
{
    public record Query : IRequest<List<string>>;

    public class Handler : IRequestHandler<Query, List<string>>
    {
        public Task<List<string>> Handle(Query request, CancellationToken cancellationToken)
        {
            var pets = new List<string> { "Dog", "Cat", "Fish" };
            return Task.FromResult(pets);
        }
    }
}

[ApiController]
[Route("api/[controller]")]
public class PetController(ISender sender) : ControllerBase
{
    [HttpGet]
    public async Task<IActionResult> GetAllPets(CancellationToken cancellationToken)
    {
        var pets = await sender.Send(new GetAllPets.Query(), cancellationToken);
        return Ok(pets);
    }
}

📦 API Overview

IRequest<TResponse>

Marker interface for requests that return a TResponse.

public interface IRequest<TResponse> { }

IRequestHandler<TRequest, TResponse>

Handles the request and returns a response.

public interface IRequestHandler<TRequest, TResponse>
    where TRequest : IRequest<TResponse>
{
    Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken);
}

ISender

Used to send requests to the appropriate handler.

public interface ISender
{
    Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default);
}

⚙️ How it Works

AddInterlink() scans the provided assembly for all classes that implement IRequestHandler<TRequest, TResponse> and registers them with the DI container. The Sender uses IServiceProvider to resolve and invoke the matching handler.


📜 License

MIT License © ManuHub

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 is compatible.  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
1.3.1 135 7/10/2025
1.3.0 156 5/4/2025
1.2.1 119 5/2/2025
1.2.0 93 4/26/2025
1.1.0 100 4/19/2025
1.0.1 215 4/15/2025
1.0.0 196 4/15/2025