Skip to content

Instantly share code, notes, and snippets.

View jonorogers's full-sized avatar

Jono Rogers jonorogers

View GitHub Profile
@jonorogers
jonorogers / DataflowExtended.cs
Created July 22, 2019 11:32
Dataflow extended
/// <summary>
/// These extensions provide resilient options for linking to cut down on boilerplate
/// They provide a null link for each real link, meaning that there is a block available which will discard messages
/// This behaivour is only really useful with a predicate; otherwise all blocks will be dropped
/// A default predicate is supplied (this may be dangerous if the caller does not understand the default behaivour?)
/// </summary>
public static class ResilientExtensions {
public static IEnumerable<IDisposable> ResilientLinkTo<TOutput>(this ISourceBlock<TOutput> source, ITargetBlock<TOutput> target) {
var link = source.LinkTo(target, x => x != null);
return GenerateNullLink(source, link);