In my application, I want to combine several lines with a dictionary of replacement values.
readTemplateBlockreceives a FileInfos file and returns their contents as a string.
getReplacersBlockreceives (once) one substitute dictionary.
joinTemplateAndReplacersBlockmust be attached to each element readTemplateBlockwith one result getReplacersBlock.
In my current setup, I need to send the same substitute dictionary again for every file that I publish.
var readTemplateBlock = new TransformBlock<FileInfo, string>(file => File.ReadAllText(file.FullName));
var getReplacersBlock = new WriteOnceBlock<IDictionary<string, string>>(null);
var joinTemplateAndReplacersBlock = new JoinBlock<string, IDictionary<string, string>>();
var propagateComplete = new DataflowLinkOptions {PropagateCompletion = true};
readTemplateBlock.LinkTo(joinTemplateAndReplacersBlock.Target1, propagateComplete);
getReplacersBlock.LinkTo(joinTemplateAndReplacersBlock.Target2, propagateComplete);
joinTemplateAndReplacersBlock.LinkTo(replaceTemplateBlock, propagateComplete);
foreach (var template in templateFilenames)
{
getFileBlock.Post(template);
}
getFileBlock.Complete();
getReplacersBlock.Post(replacers);
getReplacersBlock.Complete();
Is there a better block that I am missing? Maybe a configuration option that I missed?
source
share