1
0
mirror of synced 2024-11-16 14:53:50 +00:00
Tapeti/Helpers/MiddlewareHelper.cs

27 lines
651 B
C#
Raw Normal View History

2016-12-11 14:08:58 +00:00
using System;
using System.Collections.Generic;
namespace Tapeti.Helpers
{
public static class MiddlewareHelper
{
public static void Go<T>(IReadOnlyList<T> middleware, Action<T, Action> handle)
{
var handlerIndex = middleware.Count - 1;
if (handlerIndex == -1)
return;
Action handleNext = null;
handleNext = () =>
{
handlerIndex--;
if (handlerIndex >= 0)
handle(middleware[handlerIndex], handleNext);
};
handle(middleware[handlerIndex], handleNext);
}
}
}