Chain.NetCore 8.0.0

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

Chain Pattern for .NET

Chain is a powerful execution pattern designed for composing sequential operations in .NET. It combines aspects of the Chain of Responsibility pattern with workflow and pipeline concepts to provide flexible, ordered execution of operations.

Overview

Chain provides a clean architecture for building processing pipelines. A IChain<T> manager class orchestrates the execution of multiple ILink<T> implementations in sequence. The ExecuteAll() method iterates through each link's Execute() method, allowing the manager class to define the execution sequence.

Key Features

  • Sequential Execution: Links execute in a defined order
  • Flexible Control Flow: Links can stop execution or jump to the closing action
  • Closing Action Support: Optional post-processing method that runs after all links
  • Ready-to-Use Implementation: The EmptyChain<T> class provides out-of-the-box functionality
  • Dependency Injection Support: Integrate seamlessly with .NET Core IoC containers
  • Updated for .NET 8: Fully compatible with the latest .NET framework

Execution Control

Manager class also can have a method called ClosingAction. This action will be run after execution of all links.

Links have two control mechanisms:

  • StopExecution(): Halts the chain without running ClosingAction
  • StopPropagation(): Halts the chain but still executes ClosingAction (if defined)

Usage Examples

There is a ready to use chain called EmptyChain in this assembly. New chains can be implemented either directly from IChain or by inheriting from EmptyChain.

Basic Usage with EmptyChain

Create a simple chain by composing links together:

var message = new Message { Name = "M1" };

var c = new EmptyChain<Message>();
c.AddLink<L1>();
c.AddLink<L2>();

c.ExecuteAll(message);

Custom Chain Class

Inherit from EmptyChain for custom chain definitions:

public class L1L2Chain : EmptyChain<Message>
{
    public L1L2Chain()
    {
        AddLink<L1>();
        AddLink<L2>();
    }
}

var c = new L1L2Chain();
c.ExecuteAll(message);

Dependency Injection Integration

Define chains in your IoC container for maximum flexibility:

_container = new Container(_ => _.For<IChain<Message>>().Use(CreateChain()).Singleton());

private static IChain<Message> CreateChain()
{
    var chain = new EmptyChain<Message>();
    chain.AddLink<L1>();
    chain.AddLink<L2>();
    return chain;
}

License

MIT License - See LICENSE.md for details

Support

For issues, questions, or contributions, please visit the GitHub repository.

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 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. 
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
8.0.0 118 1/17/2026
6.0.5 1,575 12/14/2023
6.0.4 201 12/13/2023
6.0.3 217 12/13/2023
6.0.2 398 12/11/2023
6.0.1 288 12/1/2023
6.0.0 176 12/1/2023
3.1.0 12,440 1/23/2021
3.0.0 4,209 5/13/2019