/// <summary> /// Link this block to another, when it completes. /// N-th links are linked to the previous block. /// Non propagation targets(Actions blocks) are proxied and their input is used as output after invoking. /// </summary> /// <param name="target"></param> /// <param name="options"></param> public void LinkOnComplete(BaseFlowBlock <TOut, TOut> target, DataflowLinkOptions options = null) { var targetBuffer = target.GetInputBlock(); var targetAction = target.GetProcessingBlock(); if (options == null) { options = new DataflowLinkOptions() { PropagateCompletion = true } } ; //Determine the block that we'll be waiting for, since we're posting to a buffer, linked to an action block //use that block to link any secondary blocks to it! IPropagatorBlock <TOut, TOut> targetOutputBlock = null; switch (target.ProcType) { case BlockType.Action: //Create a blank transformer, and link the target to it targetOutputBlock = new TransformBlock <TOut, TOut>(x => { return(x); }); target.LinkTo(targetOutputBlock); break; case BlockType.Transform: targetOutputBlock = target._transformer; break; } //First link, link to the target's buffer if (_transformerOnCompletion == null) { _transformerOnCompletion = targetBuffer; } else { _lastTransformerBlockOnCompletion.LinkTo(targetBuffer, options); } //So that the next block can link to the output of the previous _lastTransformerBlockOnCompletion = targetOutputBlock; AddCompletionTask(target.FlowCompletion()); }
public DonutBlock(BaseFlowBlock <T, T> flowblock, IPropagatorBlock <T, FeaturesWrapper <T> > featureblock) { FlowBlock = flowblock; FeaturePropagator = featureblock; }