Giter Site home page Giter Site logo

pipelines's Introduction

Screenshot

Introduction

This package provides a simple plug and play implementation of the Pipeline Pattern. It allows you to re-use code. You can compare a pipeline to a production-line, where every stage in the production performs a certain action on a certain payload, and passes it on to the next stage. Stages can act on, manipulate, decorate, or even replace the payload.

This package is maintained by @ruudschuurmans.

Goals

  • Provide a very simple .NET Standard 2.0 implementation of the Pipeline pattern.
  • Be immutable and easily customizable/extendable to ones own needs.

Installation

This package is available on NuGet.org, so installation is as easy as running: dotnet add package Evoke.Components.Pipelines

Basic usage

If you find yourself passing results from one function to another to complete a series of tasks on a given subject, you might want to convert it into a pipeline.

using Evoke.Components.Pipelines.Interfaces;

namespace MyApplication
{
    public class Playground
    {
        // Create some stages to use in our pipeline
        // The stage interface is generic so you can provide the payload
        // type you want to run down the pipeline.
        protected class TimesTwoStage : IPipelineStage<int>
        {
            public int Process(int payload)
            {
                return payload * 2;
            }
        }

        // Create yet another stage
        protected class AddOneStage : IPipelineStage<int>
        {
            public int Process(int payload)
            {
                return payload + 1;
            }
        }

        public Playground()
        {
            // Create a pipeline
            Pipeline<int> demoPipeline = new Pipeline<int>();

            // Add the stages
            demoPipeline.Pipe(new AddOneStage())
                        .Pipe(new TimesTwoStage());
            
            // Run the pipeline with a given payload
            int result = demoPipeline.Process(1);
        }
    }
}

pipelines's People

Contributors

ruudsnl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.