DEV Community

Cover image for PipeNet, Pipe lining in .Net
Ali Alp
Ali Alp

Posted on

PipeNet, Pipe lining in .Net

Simplifying a complex logic with the Chain of responsibility and builder patterns

Install it from Nuget
Check out the Repository

Usage


OrderData result= await new Pipe<OrderData>()
    .Next(new OrderNode())
    .Next(new ProducingNode())
    .Finally(new CheckoutNode())
    .Execute(new OrderData()
    {
        Name = "Coffee"
    });


Enter fullscreen mode Exit fullscreen mode

Node 1 in the pipe

public class OrderNode : Node<OrderData>
{
    public override async Task<OrderData> Execute(OrderData param)
    {
        // Node 1's logic
        return await base.Execute(param);
    }
}
Enter fullscreen mode Exit fullscreen mode

Node 2 in the pipe

public class ProducingNode : Node<OrderData>
{
    public override async Task<OrderData> Execute(OrderData param)
    {
        // Node 2's logic
        return await base.Execute(param);
    }
}
Enter fullscreen mode Exit fullscreen mode

Node 3 in the pipe

public class CheckoutNode : Node<OrderData>
{
    public override async Task<OrderData> Execute(OrderData param)
    {
        // Node 3's logic
        return await base.Execute(param);
    }
}
Enter fullscreen mode Exit fullscreen mode

Benchmark Summary

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
WithPipeNet 221.3 ns 4.37 ns 10.87 ns 0.0713 - - 448 B
RunWithoutPipeNet 218.0 ns 4.41 ns 10.90 ns 0.0892 - - 560 B

Install it from Nuget
Check out the Repository

Happy coding :)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more