Beispiel #1
0
 /// <summary>
 /// Links to a propagator block.
 /// </summary>
 /// <typeparam name="TOutput"></typeparam>
 /// <typeparam name="TOutput2"></typeparam>
 /// <param name="builder"></param>
 /// <param name="propagatorBlock"></param>
 /// <param name="predicate"></param>
 /// <param name="declinedTargetBlock"></param>
 /// <returns></returns>
 public static ISourceDataflowBuilder <TOutput2> LinkToPropagator <TOutput, TOutput2>(
     this ISourceDataflowBuilder <TOutput> builder
     , IPropagatorBlock <TOutput, TOutput2> propagatorBlock
     , Predicate <TOutput> predicate
     , ITargetBlock <TOutput> declinedTargetBlock = null)
 {
     return(builder.LinkToPropagator(propagatorBlock, DataflowDefaultOptions.DefaultLinkOptions, predicate, declinedTargetBlock, DataflowDefaultOptions.DefaultLinkOptions));
 }
Beispiel #2
0
 /// <summary>
 /// Links to a target block.
 /// </summary>
 /// <typeparam name="TOutput"></typeparam>
 /// <param name="builder"></param>
 /// <param name="targetBlock"></param>
 /// <param name="predicate"></param>
 /// <param name="declinedTargetBlock"></param>
 /// <returns></returns>
 public static IDataflowBuilder LinkToTarget <TOutput>(
     this ISourceDataflowBuilder <TOutput> builder
     , ITargetBlock <TOutput> targetBlock
     , Predicate <TOutput> predicate
     , ITargetBlock <TOutput> declinedTargetBlock = null)
 {
     return(builder.LinkToTarget(targetBlock, DataflowDefaultOptions.DefaultLinkOptions, predicate, declinedTargetBlock, DataflowDefaultOptions.DefaultLinkOptions));
 }
Beispiel #3
0
        /// <summary>
        /// Links to a propagator block.
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <typeparam name="TOutput2"></typeparam>
        /// <param name="builder"></param>
        /// <param name="propagatorBlock"></param>
        /// <param name="linkOptions"></param>
        /// <param name="predicate"></param>
        /// <param name="declinedTargetBlock"></param>
        /// <param name="declinedLinkOptions"></param>
        /// <returns></returns>
        public static ISourceDataflowBuilder <TOutput2> LinkToPropagator <TOutput, TOutput2>(
            this ISourceDataflowBuilder <TOutput> builder
            , IPropagatorBlock <TOutput, TOutput2> propagatorBlock
            , DataflowLinkOptions linkOptions
            , Predicate <TOutput> predicate
            , ITargetBlock <TOutput> declinedTargetBlock
            , DataflowLinkOptions declinedLinkOptions)
        {
            if (builder == null)
            {
                return(null);
            }
            if (propagatorBlock == null)
            {
                throw new ArgumentNullException("propagatorBlock");
            }
            if (linkOptions == null)
            {
                throw new ArgumentNullException("linkOptions");
            }
            if (predicate == null)
            {
                throw new ArgumentNullException("predicate");
            }
            if (declinedTargetBlock == null)
            {
                throw new ArgumentNullException("declinedTargetBlock");
            }
            if (declinedLinkOptions == null)
            {
                throw new ArgumentNullException("declinedLinkOptions");
            }

            var nextBuilder = builder.LinkToPropagator(propagatorBlock, linkOptions, predicate);

            if (declinedTargetBlock != null)
            {
                // LinkTo declined target
                LinkHelper.Link((builder as SourceDataflowBuilder <TOutput>).FinalSourceBlock, declinedTargetBlock, declinedLinkOptions ?? DataflowDefaultOptions.DefaultLinkOptions);
            }

            return(nextBuilder);
        }