Chain.NetCore 6.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Chain.NetCore --version 6.0.3                
NuGet\Install-Package Chain.NetCore -Version 6.0.3                
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="6.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chain.NetCore --version 6.0.3                
#r "nuget: Chain.NetCore, 6.0.3"                
#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.
// Install Chain.NetCore as a Cake Addin
#addin nuget:?package=Chain.NetCore&version=6.0.3

// Install Chain.NetCore as a Cake Tool
#tool nuget:?package=Chain.NetCore&version=6.0.3                

chain

Chain is a pattern that I found useful in my places in my code. It is NOT the chain-of-responsibility and it is not the work-flow or pipeline. It is a combination of all.

Chain contains of a manager class that implements IChain<T> plus as many link classes which they should implement ILink<T>. 'IChain' have a methid called 'ExecuteAll()' which technically goes thourgh the Execute() method of all links and run them one by one. The manager class is responsible to define the sequence of the links.

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

Each links has two different abilities. They can stop execution of the chain, and they can stop propagation of the chain and jump to ClosingAction. The difference between two is that ClosingAction method, if exists, won't be run for StopExecution() but it will for StopPropagation().

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.

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

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

c.ExecuteAll(message);

EmptyChain can also be used in a different way:

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

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

Chains can also be created in IoC registration. This gives the flexibility to define the sequence of the chain in the IoC.

_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;
}
Product 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 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. 
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
6.0.5 560 12/14/2023
6.0.4 124 12/13/2023
6.0.3 127 12/13/2023
6.0.2 284 12/11/2023
6.0.1 191 12/1/2023
6.0.0 115 12/1/2023
3.1.0 12,238 1/23/2021
3.0.0 4,002 5/13/2019