Ejemplo n.º 1
0
            public PipelineCoordinator EndWith(Action <PipelineSource <T> > sinkAction)
            {
                PipelineSource <T> source = new PipelineSource <T>(coordinator);

                currentSink.AttachSource(source);
                coordinator.AddInitialAction(() => sinkAction(source));
                return(coordinator);
            }
Ejemplo n.º 2
0
            public Incomplete <TResult> Then <TResult>(Action <PipelineSource <T>, PipelineSink <TResult> > connector)
            {
                PipelineSource <T> source = new PipelineSource <T>(coordinator);

                currentSink.AttachSource(source);
                PipelineSink <TResult> newSink = new PipelineSink <TResult>(coordinator);

                coordinator.AddInitialAction(() => connector(source, newSink));
                return(new Incomplete <TResult>(newSink, coordinator));
            }
Ejemplo n.º 3
0
        private async static void DumpItems(PipelineSource <string> source)
        {
            Tuple <bool, string> current = await source.Receive();

            while (current.Item1)
            {
                Console.WriteLine("Received message = '{0}'", current.Item2);
                current = await source.Receive();
            }
        }
Ejemplo n.º 4
0
        private async static void TransformItems(PipelineSource <int> source, PipelineSink <string> sink)
        {
            Tuple <bool, int> current = await source.Receive();

            while (current.Item1)
            {
                await sink.Yield("Got " + current.Item2);

                current = await source.Receive();
            }
        }
Ejemplo n.º 5
0
        private async static void FilterItems(PipelineSource <int> source, PipelineSink <int> sink)
        {
            Tuple <bool, int> current = await source.Receive();

            while (current.Item1)
            {
                int value = current.Item2;
                // Yield even numbers once, and multiples of 3 once (so 0 and 6 will be yielded twice each)
                if (value % 2 == 0)
                {
                    await sink.Yield(value);
                }
                if (value % 3 == 0)
                {
                    await sink.Yield(value);
                }
                current = await source.Receive();
            }
        }
Ejemplo n.º 6
0
 internal void AttachSource(PipelineSource <T> attachedSource)
 {
     this.attachedSource = attachedSource;
 }