/Jcd.DoWhenRun

A netstandard 1.0 set of extension methods, Do, DoWhen and Run, that give a Fluent builder-pattern-like experience to operating on IEnumerable and IEnumerable<T> derived types. Support me at https://ko-fi.com/jasoncdaniels

Primary LanguageC#MIT LicenseMIT

Jcd.DoWhenRun

A netstandard 1.0 set of extension methods, Do, DoWhen and Run, that give a Fluent builder-pattern-like experience to operating on IEnumerable and IEnumerable<T> derived types.

Do

Do sets up an operation to perform on every item it iterates across.

DoWhen

DoWhen sets up an operation to perform on every item it iterates across that matches the predicate.

Run

Run enumerates an IEnumerable and therefore causes execution of the the code configured in Do and DoWhen blocks.

Example

    (from x in Enumerable.Range(0, 4)
     from y in Enumerable.Range(0, 4)
     select (x, y))
        .DoWhen((i,_)=>i > 0 && i % 4 == 0, (_,_)=>Console.WriteLine())
        .Do(t=>Console.Write(t))
        .Run();

    Console.WriteLine();
    
    /* outputs:
        (0, 0)(0, 1)(0, 2)(0, 3)
        (1, 0)(1, 1)(1, 2)(1, 3)
        (2, 0)(2, 1)(2, 2)(2, 3)
        (3, 0)(3, 1)(3, 2)(3, 3)            
    */            

GitHub Build status CodeFactor Grade

MyGet Nuget

API Docs