Pipe

        public static R Pipe<T, R>(this T o, Func<T, R> func)
        {
            if (func == null) throw new ArgumentNullException("func", "'func' can not be null.");
            T buffer = o;
            return func(buffer);
        }
        public static T Pipe<T>(this T o, Action<T> action)
        {
            if (action == null) throw new ArgumentNullException("action", "'action' can not be null.");
            T buffer = o;
            action(buffer);
            return buffer;
        }
Example:
<%= variable.Pipe(x => this.Fun1(x)).Pipe(x =>
{
    ...;
    return this.F2(x);
}) %>

Description

It is like pipe operator in F# and is useful for chaining function calls especially in expressions. (More in http://foop.codeplex.com/)

Details

Double click on the code to select all.

 

;