public void LinkCandidate( ITargetHook <T> target, DataflowLinkOptions options = null, Predicate <T> predicate = null) { if (!BlockInfo.IsSourceBlock) { throw new Exception("Only source block can linked candidates"); } var candidate = new LinkCandidateInformation <T>(_visitor, this, target, options, predicate); _visitor.AddLinkCandidate(candidate); }
/// <summary> /// Links the source to the specified target /// </summary> /// <param name="target">The target.</param> /// <param name="linkOptions">The link options.</param> /// <param name="predicate">The predicate.</param> /// <returns></returns> public IDisposable LinkTo( ITargetBlock <T> target, DataflowLinkOptions linkOptions, Predicate <T> predicate) { if (!BlockInfo.IsSourceBlock) { throw new Exception("Only source block can linked to"); } var targetHook = target as ITargetHook <T>; LinkCandidateInformation <T> candidate = null; if (targetHook != null) { candidate = new LinkCandidateInformation <T>(_visitor, this, targetHook, linkOptions, predicate); } var hook = new LinkHook <T>(this, target, linkOptions, _visitor, predicate, candidate); _visitor.AddLink(hook.LinkInfo); return(hook); }
public LinkHook( ISourceHook <T> source, ITargetBlock <T> target, DataflowLinkOptions linkOptions, DataflowVisitor visitor, Predicate <T> predicate = null, LinkCandidateInformation <T> candidate = null) { _target = target; var targetHook = target as ITargetHook <T>; if (targetHook != null) { _targetName = targetHook.BlockInfo.Name; _targetInfo = targetHook.BlockInfo; } _source = source; _candidate = candidate; if (candidate != null) { LinkInfo = new LinkToInformation(candidate.Connector, linkOptions, UnLink); } if (predicate == null) { _disposal = _source.InternalSource.LinkTo(this, linkOptions); } else { _disposal = DataflowBlock.LinkTo(_source.InternalSource, this, linkOptions, predicate); } _visitor = visitor; }