csharp/71/Cometary/src/Cometary.Core/Internal/Pipeline.cs

Pipeline.cs
using System;
using System.Diagnostics.Codeastysis;

namespace Cometary
{
    /// 
    /// 
    /// 
    [SuppressMessage("Compiler", "CS0702", Justification = "That constraint is annoying.")]
    internal sealed clast Pipeline where TDelegate : Delegate
    {
        private readonly LightList Components;

        public Pipeline()
        {
            Components = new LightList();
        }

        public TDelegate MakeDelegate(TDelegate @default)
        {
            var components = Components.UnderlyingArray;
            var next = @default;

            for (int i = components.Length - 1; i >= 0; i--)
            {
                next = components[i](next);
            }

            return next;
        }

        public void Add(PipelineComponent component)
        {
            Components.Add(component);
        }

        public void Remove(PipelineComponent component)
        {
            Components.Remove(component);
        }
    }
}