What is the opposite block of BatchBlock

孤者浪人 提交于 2020-01-24 19:00:33

问题


Given:

A list of ids of emails

What I'm doing:

With the BatchBlock group ids and call a Transformblock for each block the simplified transformblock looks like this:

var readBatch = new TransformBlock<List<int>, IEnumerable<Email>>(idList =>
{
    List<Email> mails = new List<Email>();
    foreach(var id in idList)
    {
        mails.Add(new Email(id));
    }
    return mails;
});

Now my next TransformBlock is defined like this

TransformBlock<Email,EMail> filterStep;

What I search: So I need a block which allows me to get a collection as source and returns N-Elements as result. So in this case a block which receives a IEnumerable<Email> and returns Email foreach entryin the enumeration.

So what I search is the opposite of the BatchBlock but i can't find it. Am I overlooking something?


回答1:


The block you need is TransformManyBlock. You return an IEnumerable<Email> from the the block's func and it automatically transfers each item individually:

var transformManyBlock = new TransformManyBlock<IEnumerable<Email>, Email>(emails => emails);



回答2:


TransformManyBlock might be what you are looking for. It takes TInput and returns IEnumerable (1:n).



来源:https://stackoverflow.com/questions/32422003/what-is-the-opposite-block-of-batchblock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!