Skip to content

alunacjones/LSL.CompositeHandlers

Repository files navigation

Build status codecov NuGet

LSL.CompositeHandlers

A factory for building a compound function using "next" semantics similar to node.js express middleware.

Quick Start

var factory = new CompositeHandlerFactory();
var handler = factory.Create(new HandlerDelegate<int, string>[] { 
    (context, next) => context == 2 ? "We stop on the number 2" : next(),
    (context, next) => context < 10 ? $"Doubled value {context * 2}": next()
},
cfg => cfg.WithDefaultHandler(context => $"Reached the end with {context}"));

Console.WriteLine(handler(1)); // Returns "Doubled value 2" 
Console.WriteLine(handler(2)); // Returns "We stop on the number 2"
Console.WriteLine(handler(12)); // Returns "Reached the end with 12"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages