Skip to content
ahzf edited this page Feb 23, 2011 · 6 revisions

The pipes that come prepackaged with Pipes.NET are not sufficient for every use case. In many situations, it will be necessary to create a pipe that will solve a particular mapping from an input to an output. Pipes make it easy to create new pipes with the AbstractPipe<S, E> class, as in most cases there is just a single method that needs to be implemented: Boolean AbstractPipe.MoveNext(). The example below demonstrates the internals of a simple pipe that maps a string to the number of characters contained in that string.

public class CharacterCountPipe : AbstractPipe<String, UInt64>
{
    public override Boolean MoveNext()
    {

        if (_InternalEnumerator == null)
            return false;

        if (_InternalEnumerator.MoveNext())
        {
            _CurrentElement = (UInt64) _InternalEnumerator.Current.Length;
            return true;
        }

        return false;

    }
}

Basic Pipes home Filtering Pipes