Пример #1
0
        /// <summary>
        /// Links a dataflow to multiple targets. Uses DataBroadcaster internally.
        /// </summary>
        /// <typeparam name="TIn">The input type of the Dataflow</typeparam>
        /// <typeparam name="TOut">The output type of the Dataflow</typeparam>
        /// <param name="dataflow">The source dataflow</param>
        /// <param name="out1">The first target dataflow</param>
        /// <param name="out2">The second target dataflow</param>
        /// <param name="copyFunc">The copy function</param>
        public static void LinkToMultiple <TIn, TOut>(this Dataflow <TIn, TOut> dataflow, IDataflow <TOut> out1, IDataflow <TOut> out2, Func <TOut, TOut> copyFunc = null)
        {
            var brancher = new DataBroadcaster <TOut>(copyFunc, DataflowOptions.Default);

            dataflow.GoTo(brancher);
            brancher.LinkTo(out1);
            brancher.LinkTo(out2);
        }
Пример #2
0
        /// <summary>
        /// Links a dataflow to multiple targets. Uses DataBroadcaster internally.
        /// </summary>
        /// <typeparam name="TIn">The input type of the Dataflow</typeparam>
        /// <typeparam name="TOut">The output type of the Dataflow</typeparam>
        /// <param name="dataflow">The source dataflow</param>
        /// <param name="copyFunc">The copy function</param>
        /// <param name="outs">The target dataflows</param>
        public static void LinkToMultiple <TIn, TOut>(this Dataflow <TIn, TOut> dataflow, Func <TOut, TOut> copyFunc, params IDataflow <TOut>[] outs)
        {
            var brancher = new DataBroadcaster <TOut>(copyFunc, DataflowOptions.Default);

            dataflow.GoTo(brancher);

            foreach (var output in outs)
            {
                brancher.LinkTo(output);
            }
        }