Exemple #1
0
 /// <summary>
 /// Links to target block.
 /// </summary>
 /// <typeparam name="TInput"></typeparam>
 /// <typeparam name="TOutput"></typeparam>
 /// <param name="builder"></param>
 /// <param name="targetBlock"></param>
 /// <param name="predicate"></param>
 /// <param name="declinedTargetBlock"></param>
 /// <returns></returns>
 public static ITargetDataflowBuilder <TInput> LinkToTarget <TInput, TOutput>(
     this IPropagatorDataflowBuilder <TInput, TOutput> builder
     , ITargetBlock <TOutput> targetBlock
     , Predicate <TOutput> predicate
     , ITargetBlock <TOutput> declinedTargetBlock = null)
 {
     return(builder.LinkToTarget(targetBlock, DataflowDefaultOptions.DefaultLinkOptions, predicate, declinedTargetBlock, DataflowDefaultOptions.DefaultLinkOptions));
 }
Exemple #2
0
        /// <summary>
        /// Links to target block.
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="builder"></param>
        /// <param name="targetBlock"></param>
        /// <param name="linkOptions"></param>
        /// <param name="predicate"></param>
        /// <param name="declinedTargetBlock"></param>
        /// <param name="declinedLinkOptions"></param>
        /// <returns></returns>
        public static ITargetDataflowBuilder <TInput> LinkToTarget <TInput, TOutput>(
            this IPropagatorDataflowBuilder <TInput, TOutput> builder
            , ITargetBlock <TOutput> targetBlock
            , DataflowLinkOptions linkOptions
            , Predicate <TOutput> predicate
            , ITargetBlock <TOutput> declinedTargetBlock
            , DataflowLinkOptions declinedLinkOptions)
        {
            if (builder == null)
            {
                return(null);
            }
            if (targetBlock == null)
            {
                throw new ArgumentNullException("targetBlock");
            }
            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.LinkToTarget(targetBlock, linkOptions, predicate);

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

            return(nextBuilder);
        }